Proposal: Array.prototype.accumulate and Array.prototype.accumulateRight

Mark M. Young mark at
Thu Oct 27 18:38:11 UTC 2016

I am proposing a replacement for Array.prototype.reduce and Array.prototype.reduceRight.  The main improvements are 1) iteration always starts at index 0 (or k-1 in the case of accumulateRight) on non-empty arrays and 2) it allows definition of callbackFn's ‘this' context just like ‘every’, ‘filter’, ‘find’, ‘findIndex’, ‘forEach’, ‘map', and ‘some’.

The code is simple, but I have included much explanation because of the blank stares I get from people when I say “the problem with Array reduce” so I anticipate resistance.  Please visit the GitHub repo. and review on here. <>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list