JavaScript Map Reference
The Map Object
A Map object holds key-value pairs where the keys can be any datatype.
A Map remembers the original insertion order of the keys.
// Create a Map
const fruits = new Map([
["apples", 500],
["bananas", 300],
["oranges", 200]
]);
Try it Yourself »
See Also:
Complete Set Reference
Revised July 2025
Method | Description |
---|---|
new Map() | Creates a new Map object |
clear() | Removes all the elements from a Map |
delete() | Removes a Map element specified by a key |
entries() | Returns an iterator object with the [key, value] pairs in a Map |
forEach() | Invokes a callback for each key/value pair in a Map |
get() | Gets the value for a key in a Map |
groupBy() | Groups object elements according to returned callback values |
has() | Returns true if a key exists in a Map |
keys() | Returns an iterator object with the keys in a Map |
set() | Sets the value for a key in a Map |
size | Returns the number of Map elements |
values() | Returns an iterator object of the values in a Map |