When using the Javascript built in Map, how do you use .map() to iterate over the keys?
I know the for...of can be used as shown below:
const map = new Map();
map.set(0, 'Zero');
map.set(1, 'One');
map.set(2, 'Two');
for (let key of map.keys()) {
console.log(key);
}
But this code will fail:
map.keys().map(key => {
console.log(key);
});
for..of
because it conforms to the iterator protocol already. – Bloodstock