Can we please start talking about Iterators already? The Python community are laughing at us! Widening the Array prototype is like putting lipstick on a pig...
On Thursday, 27 October 2016, Bergi <[email protected]> wrote: > Mark M. Young wrote: > >> I am proposing a replacement for Array.prototype.reduce and >> Array.prototype.reduceRight. >> > > Nice. Allowing to pass an argument for the `this` value was missing when > folding an array, and your suggestion `accumulate` is a fitting method name. > > However, I fear the use cases are too unimportant to need a fix. > The `this` keyword is becoming less and less used for anything but class > methods. And for those, arrow functions solve the problem needing to invoke > functions on the expected receiver. > For passing in data to a reusable reducer function, closures are much > simpler than setting the `this` value for the callback. > > https://github.com/MarkMYoung/ArrayAccumulate < > https://github.com/MarkMYoung/ArrayAccumulate> says > >> `reduce` is not reusable code because there is no way to know what the >> second parameter was once beyond the first iteration. >> > > That makes no sense. The whole point of the initial value parameter is > that it only goes into the first call (if any), or is the return value in > case the array is empty. > > the second parameter is always available as `this`. >> > > It really should not be. If you want to pass a value for `this`, it needs > a third parameter. > > kind regards, > Bergi > _______________________________________________ > es-discuss mailing list > [email protected] > https://mail.mozilla.org/listinfo/es-discuss >
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

