W3cubDocs

/JavaScript

Map.map

The Map() creates Map objects.

Syntax

new Map([iterable])

Parameters

iterable
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

Browser compatibilityUpdate compatibility data on GitHub

Desktop
Chrome Edge Firefox Internet Explorer Opera Safari
Map() constructor 38 12 13 11 25 8
new Map(iterable) 38 12 13 No 25 9
Map() without new throws 38 12 42 11 25 9
new Map(null) 38 12 37 11 25 9
Mobile
Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
Map() constructor 38 38 14 25 8 3.0
new Map(iterable) 38 38 14 25 9 3.0
Map() without new throws 38 38 42 25 9 3.0
new Map(null) 38 38 37 25 9 3.0
Server
Node.js
Map() constructor 0.12
0.12
0.10
Disabled
Disabled From version 0.10: this feature is behind the --harmony runtime flag.
new Map(iterable) 0.12
Map() without new throws 0.12
new Map(null) 0.12
0.12
0.10
Disabled
Disabled From version 0.10: this feature is behind the --harmony runtime flag.

See also

© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://wiki.developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/Map