Map
Last updated
Last updated
The Map object holds key-value pairs and remembers the original insertion order of the keys. Any value (both objects and primitive values) may be used as either a key or a value.
For more information see: Map (MDN).
Type | Name | Summary |
---|---|---|
Type | Name | Summary |
---|---|---|
The size accessor property returns the number of elements in a Map object.
Type Number
Sample
The clear() method removes all elements from a Map object.
Returns: void
Sample
The delete() method removes the specified element from a Map object by key.
Parameters
Object key ;
Returns: Boolean
Sample
The entries() method returns a new iterator object that contains the [key, value] pairs for each element in the Map object in insertion order. In this particular case, this iterator object is also an iterable, so the for-of loop can be used..
Returns: Iterator the iterator that can be used in for of loops
Sample
The forEach() method executes a provided function once for each value in the Map object, in insertion order.
Parameters
Returns: void
Sample
The get() method returns a specified element from a Map object. If the value that is associated to the provided key is an object, then you will get a reference to that object and any change made to that object will effectively modify it inside the Map object.
Parameters
Object key ;
Returns: Object
Sample
The has() method returns a boolean indicating whether an element with the specified key exists in a Map object or not.
Parameters
Object key ;
Returns: Boolean
Sample
The keys() method returns a new iterator object that contains the keys for each element in the Map object in insertion order. In this particular case, this iterator object is also an iterable, so a for...of loop can be used.
Returns: Iterator the iterator that can be used in for of loops
Sample
The set() method adds or updates an entry in a Map object with a specified key and a value.
Parameters
Returns: Map
Sample
The values() method returns a new iterator object that contains the values for each element in the Map object in insertion order.
Returns: Iterator the iterator that can be used in for of loops
Sample
The size accessor property returns the number of elements in a Map object.
void
The clear() method removes all elements from a Map object.
The delete() method removes the specified element from a Map object by key.
The entries() method returns a new iterator object that contains the [key, value] pairs for each element in the Map object in insertion order.
void
The forEach() method executes a provided function once for each value in the Map object, in insertion order.
The get() method returns a specified element from a Map object.
The has() method returns a boolean indicating whether an element with the specified key exists in a Map object or not.
The keys() method returns a new iterator object that contains the keys for each element in the Map object in insertion order.
The set() method adds or updates an entry in a Map object with a specified key and a value.
The values() method returns a new iterator object that contains the values for each element in the Map object in insertion order.