JS: Literal Expression for Map
Literal Expression for Map
There's no literal expression for map. But you can pass in a literal expression of array of array, like this:
new Map([ [k1, v1], [k2, v2], etc])
const xx = new Map([[3, "n3"], [4, "n4"]]); console.log(xx); // Map { 3 => "n3", 4 => "n4" }
Note: the map constructor (new Map()) does not accept a object datatype.