Javascript Map constructor

Introduction

The Map() constructor creates Map objects.

new Map([iterable])
  • iterable - an Array or other iterable object whose elements are key-value pairs.

Arrays with two elements, such as [[ 1, 'one' ],[ 2, 'two' ]].)

let myMap = new Map([
  [1, 'one'],/*  w w w.j  ava  2s .co m*/
  [2, 'two'],
  [3, 'three'],
]);

console.log(myMap);



PreviousNext

Related