The Map()
constructor 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 newMap
.
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
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Desktop | Mobile | Server | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Map() constructor | Chrome Full support 38 | Edge Full support 12 | Firefox Full support 13 | IE Full support 11 | Opera Full support 25 | Safari Full support 8 | WebView Android Full support 38 | Chrome Android Full support 38 | Firefox Android Full support 14 | Opera Android Full support 25 | Safari iOS Full support 8 | Samsung Internet Android Full support 3.0 | nodejs
Full support
0.12
|
new Map(iterable) | Chrome Full support 38 | Edge Full support 12 | Firefox Full support 13 | IE No support No | Opera Full support 25 | Safari Full support 9 | WebView Android Full support 38 | Chrome Android Full support 38 | Firefox Android Full support 14 | Opera Android Full support 25 | Safari iOS Full support 9 | Samsung Internet Android Full support 3.0 | nodejs Full support 0.12 |
Map() without new throws | Chrome Full support 38 | Edge Full support 12 | Firefox Full support 42 | IE Full support 11 | Opera Full support 25 | Safari Full support 9 | WebView Android Full support 38 | Chrome Android Full support 38 | Firefox Android Full support 42 | Opera Android Full support 25 | Safari iOS Full support 9 | Samsung Internet Android Full support 3.0 | nodejs Full support 0.12 |
new Map(null) | Chrome Full support 38 | Edge Full support 12 | Firefox Full support 37 | IE Full support 11 | Opera Full support 25 | Safari Full support 9 | WebView Android Full support 38 | Chrome Android Full support 38 | Firefox Android Full support 37 | Opera Android Full support 25 | Safari iOS Full support 9 | Samsung Internet Android Full support 3.0 | nodejs
Full support
0.12
|
Legend
- Full support
- Full support
- No support
- No support
- User must explicitly enable this feature.
- User must explicitly enable this feature.