Map() constructor
BaselineWidely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
TheMap()
constructor createsMap
objects.
Syntax
Parameters
iterable
OptionalAn
Array
or otheriterable objectwhose elements are key-value pairs. (For example, arrays with two elements,such as[[ 1, 'one' ],[ 2, 'two' ]]
.) Each key-value pair is added to thenewMap
.
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 |