Logo

Programming-Idioms

History of Idiom 8 > diff from v54 to v55

Edit summary for version 55 by javajosh:
[JS] Make more consistent with the other examples

Version 54

2019-09-26, 19:49:53

Version 55

2019-09-26, 19:50:46

Idiom #8 Initialize a new map (associative array)

Declare a new map object x, and provide some (key, value) pairs as initial content.

Idiom #8 Initialize a new map (associative array)

Declare a new map object x, and provide some (key, value) pairs as initial content.

Extra Keywords
table dictionary hash
Extra Keywords
table dictionary hash
Code
let x = new Map([["a",1],["b",2]]);
Code
const x = new Map([["one",1],["two",2]]);
Comments bubble
The Map constructor can take an array of [key, value] pairs.
Comments bubble
The Map constructor can take an array of [key, value] pairs.
Doc URL
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map
Doc URL
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map
Demo URL
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map
Demo URL
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map