Map() constructor

The Map() constructor creates Map objects.

Syntax

new Map([iterable])

Parameters

iterable Optional
An Array or other iterable object whose elements are key-value pairs. (For example, arrays with two elements, such as [[ 1, 'one' ],[ 2, 'two' ]].) Each key-value pair is added to the new Map.

Examples

Creating a new Map

let myMap = new Map([
  [1, 'one'],
  [2, 'two'],
  [3, 'three'],
])

Specifications

Specification
ECMAScript (ECMA-262)
The definition of 'Map constructor' in that specification.

Browser compatibility

BCD tables only load in the browser

See also