JavaScript’s map function is extremely useful, but it can also be a bit confusing when you’re just starting out with programming.
The Map object holds key-value pairs. Any value (both objects and primitive values) may be used as either a key or a value.
It is datastructure to solve real world problems.
let map = new Map(); // Here creating map object and map methods to iterate over map
Removes all key/value pairs from the Map object.
Removes any value associated to the key and returns the value that Map.prototype.has(key) would have previously returned.
will return false afterwards.
Returns a new Iterator object that contains an array of [key, value] for each element in the Map object in insertion order.
Calls callbackFn once for each key-value pair present in the Map object, in insertion order. If a thisArg parameter is provided to forEach, it will be used as the this value for each callback.
Returns the value associated to the key, or undefined if there is none.
Map.prototype.has(key)
Returns a boolean asserting whether a value has been associated to the key in the Map object or not.
Returns a new Iterator object that contains the keys for each element in the Map object in insertion order.
Sets the value for the key in the Map object. Returns the Map object.
Returns a new Iterator object that contains the values for each element in the Map object in insertion order.