Map
A Map object holds key-value pairs, where any value (both objects and primitive values) may be used as either a key or a value. Insertion order is remembered, which allows iteration in that order.
set(key, value) function
Add or update an entry in the Map with the specified key and value.
key: The key of the element to add or update.
value: The value associated with the key.
Returns: The Map object (for chaining).
get(key) function
Return the value associated with the specified key, or undefined if no such key exists.
key: The key of the element to retrieve.
Returns: The value associated with the key, or undefined if not found.
has(key) function
Return a boolean indicating whether the Map contains an element with the specified key.
key: The key to test for presence in the Map.
Returns: True if the key is found, otherwise false.
delete(key) function
Remove the specified key and its associated value from the Map, if it exists.
key: The key to remove.
Returns: True if an element was removed, otherwise false.
clear() function
Remove all entries from the Map, leaving it empty.
Returns: None
size accessor
(read only)
A read-only property returning the number of key-value pairs in the Map.
Returns: The number of entries in the Map.
forEach(callbackFn, thisArg) function
Execute a provided callback function once per each key-value pair in the Map, in insertion order.
callbackFn: A function(value, key, map) to execute on each entry.
thisArg: Optional. A value to use as 'this' when executing callbackFn.
Returns: None
values() function
Return a new Iterator object that contains the values for each element in the Map, in insertion order.
Returns: An iterator of the Map's values.
keys() function
Return a new Iterator object that contains the keys for each element in the Map, in insertion order.
Returns: An iterator of the Map's keys.
entries() function
Return a new Iterator object that contains the [key, value] pairs for each element in the Map, in insertion order.
Returns: An iterator of [key, value] pairs.