Map
Last updated
Was this helpful?
Last updated
Was this helpful?
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: .
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.
The size accessor property returns the number of elements in a Map object.
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
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..
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
Sample
The has() method returns a boolean indicating whether an element with the specified key exists in a Map object or not.
Parameters
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.
Sample
The set() method adds or updates an entry in a Map object with a specified key and a value.
Parameters
Sample
The values() method returns a new iterator object that contains the values for each element in the Map object in insertion order.
Sample
Type
key ;
Returns:
Returns: the iterator that can be used in for of loops
callback ;
thisArgument ;
key ;
Returns:
key ;
Returns:
Returns: the iterator that can be used in for of loops
key ;
value ;
Returns:
Returns: the iterator that can be used in for of loops