Right now [].reduce doesn't take an optional thisArg, so the callback
is always called with |null| for |this| per 9.c.ii.

The Array prototype object take an optional thisArg for every, some,
forEach, map, and filter; so it would be good to make reduce
consistent with the rest.

The new parameter list for Array.prototype.reduce would then be..

15.4.4.21 Array.prototype.reduce ( callbackfn [ , initialValue [ ,
thisArg ] ] )

Insert after step 4:
#. If thisArg was supplied, let T be thisArg; else let T be undefined.

For step 9.c.ii, replace:
"callbackfn with null as the this value" with..
"callbackfn with T as the this value"

Similarly, this should be applied to reduceRight as well:
15.4.4.22 Array.prototype.reduceRight ( callbackfn [ , initialValue [
, thisArg ] ] )

The only remaining Array callback is sort, which could be updated as well:
15.4.4.11 Array.prototype.sort ( comparefn [, thisArg ] )

Ed
_______________________________________________
Es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to