How to iterate a Map in Javascript

 

 

Iterating a Map

For iterating over a Map, we can use the following javascript constructs:

 

let mapV = new Map()

mapV.set("one", 1);
mapV.set("two", 2);
mapV.set(3, 3);

for (let [key, value] of mapV) {
console.log(key + " = " + value);
}

Tags:

Share:

Related posts