To call map() on an iterator with JavaScript, we convert the iterator into an array.
For instance, we write
Array.from(m).map(([key, value]) => {
//...
});
to call Array.from
with iterator m
to convert it to an array.
Then we get the key
and value
from the array parameter in the map
callback and do what we want with the values.
Conclusion
To call map() on an iterator with JavaScript, we convert the iterator into an array.