I can use a Map
and then set values:
const a = new Map([["a", "b"], ["c", "d"]])
Now if I want to apply a function to all values in a functional way (without for ... of
or .forEach
), I thought I could have done something like this:
const b = a.map(([k, v]) => [k, doSomethingWith(v)]);
But there is no map
function on a Map
. Is there a built-in/elegant way to map a Map
?
Map#entries
then.map
on thema.entries().map(...)
– MooneyMap.entries()
return an Iterator (not Array); and Iterators haven't.map
method... – Cristencristi