Theory
A hash table stores data using key-value pairs. A hashing function is used to determine where a value should be stored. Hash tables provide very fast average-case lookup, insertion and deletion.
Example
const users = new Map();
users.set("name", "Prachi");
users.set("role", "Developer");
console.log(users.get("name"));
Expected Output
Prachi
Practice
Create a Map containing student names and their marks.
Interview Questions
- What is a hash table?
- What is hashing?
- What is a key-value pair?
- Why are hash tables useful?