« Bugzilla Issues Index

#591 — Set.prototype.forEach

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

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

value, value, set


let s = new Set();


s.forEach(( value, value, set ) => {
console.log( value );

// "hi"
// 42

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

callbackfn should be a function that accepts three arguments. forEach calls callbackfn once for each value present in the set, in the order that that the values were added.

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 instead.

callbackfn is called with three arguments: the current value, the current value again for API consistency 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 correct.

in October 26, 2012 release draft

Page. 327, the callbackFn args are missing the second arg

changed to call callbackfn with three arguments.

updated in rev 12 editor's draft.

corrected in rev 12, Nov. 22, 2012 draft