Calls a callback function once for each key-value pair present in the Map object, in insertion order.
forEach(callback, thisArg?)
callback function(value, key, map)
A function that accepts up to three arguments: the value of the current element, the key of the element, the original map. It is called one time for each element of the map.
thisArg optional
An object to which the this keyword is bound in the callback function. If omitted, undefined is used as the this value.
forEach is useful for performing side-effects with map elements.
const map = new Map()
map.set("first", "numero uno").set("second", "numero dos")
map.forEach((value, key) => print(`${key}: ${value}`))
first: numero uno
second: numero dos