« Bugzilla Issues Index

#592 — Map.prototype.forEach

Per resolution on July 26th at the in-person TC39 meeting...

Map.prototype.forEach, behaving similarly to Array.prototype.forEach, but whose
callbackFn receives arguments in this order:

value, key, map


let m = new Map();
let a = {};

m.set( a, "foo" );

m.forEach(( value, key, map ) => {
console.log( value, key );

// "foo", {}

Map.prototype.forEach ( callbackfn [ , thisArg ] )

callbackfn should be a function that accepts three arguments. forEach calls
callbackfn once for each key present in the map, in the order that that the
keys were set.

If a thisArg parameter is provided, it will be used as the |this| value for
each invocation of callbackfn. If it is not provided, undefined is used

callbackfn is called with three arguments: the current value, the current key
and the set instance object itself.

**NOTE** This was a basic attempt to match the sematics of
Array.prototype.forEach for API consistency. I concede that it may not all be

added to editor's draft

fixed in rev10, Sept. 27 2012 draft