Map: Initialize:
Const MAPSIZE = (new Map ()). Size; mapsize:0
Const PAIR1 = [1, ' one '];
Const PAIR2 = [2, ' both '];
Const MAP = new Map ([Pair1, Pair2]); New Map (). Set (... pair1). Set (... pair2);
Whichever is the last set value:
Const PAIR1 = [1, ' one '];
Const PAIR2 = [1, ' Uno '];
Const PAIR3 = [1, ' eins '];
Const PAIR4 = [2, ' both '];
Const MAP = new Map ([Pair1, Pair2, Pair3, PAIR4]); New Map (). Set (... pair3). Set (... pair4);
Let map = new map ();
Const OBJ = {x:1, y:2};
Const KEYS = Object.keys (obj);
Keys.foreach (key = Map.set (key, Obj[key]));
Set, GET, has:
Let map = new map ();
Map.set (' key ', ' value '); Set can be used with OH
Const VALUE = map.get (' key ');
You can use anything to make a key OH:
Let map = new map ();
Const OBJ = {};
Map.set ({}, ' object is key ');
There is also the has method:
Let map = new map ([[' Key ', ' VALUE ']]);
Const HASKEY = Map.has (' key ');
Keys and Values method:
Let map = new map ();
Map.set (1, ' one '). Set (2, ' one ');
Assert.deepequal ([... Map.keys ()], [+]);
Assert.deepequal ([... map.values ()], [' One ', ' both ']);
Learn some es6:map.