Set and Map additions in the latest draft
brendan at mozilla.org
Mon Oct 29 12:39:31 PDT 2012
Claus Reinke wrote:
>>> I thought it was agreed that the function passed to
>>> Set.prototype.forEach would be called with 3 arguments, the value, the
>>> value again and the context object. This is so that one can use the
>>> same function for Array.prototype.forEach, Map.prototype.forEach and
>> Yes, I've reopened the bug for this:
> Isn't an adapter supporting the use case as simple as:
> (v,s) => f(v,v,s) ?
Not if everyone has to write that and wrap it around an
otherwise-reusable f when sharing f among maps, weakmaps and sets.
> More generally, is it really a good idea to treat Sets as "Arrays
> without duplicate elements"?
That's not the treatment here. The treatment is uniform signature for a
shared forEach callback.
With object model reformation, one could even make set[v] evaluate to
More information about the es-discuss