Map() constructor
Baseline
Widely available
This feature is well established and works across many devices and browser versions. Itâs been available across browsers since â¨July 2015â©.
The Map() constructor creates Map objects.
Syntax
js
new Map()
new Map(iterable)
Parameters
iterableOptional-
If an iterable object (such as an array) is passed, all of its elements will be added to the new
Map. Each element must be an object with two properties:0and1, which correspond to the key and value (for example,[[1, "one"],[2, "two"]]). If you don't specify this parameter, or its value isnullorundefined, the newMapis empty.
Examples
>Creating a new Map
js
const myMap = new Map([
[1, "one"],
[2, "two"],
[3, "three"],
]);
Specifications
| Specification |
|---|
| ECMAScript® 2026 Language Specification > # sec-map-constructor > |