Map.prototype.forEach

Calls a callback function once for each key-value pair present in the Map object, in insertion order.

Syntax

forEach(callback, thisArg?)

Parameters

Remarks

forEach is useful for performing side-effects with map elements.

Examples

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