Mastery Points
0
Maps with JS in dsa
Context & Logic
A Map is a collection of keyed data items, similar to an Object. But the main difference is that Map allows keys of any type.
Example
const myMap = new Map();
myMap.set('name', 'Punam');
myMap.set(1, 'One');
console.log(myMap.get(1)); // 'One'Step-by-Step Logic
1
Set: Map a key to a value.
2
Get: Retrieve the value associated with a key.
3
Has: Check existence of a key.
4
Size: Get the number of entries directly.
Complexity Metrics
Time Efficiency
O(1) average for set/get/has
Memory Footprint
O(n)