Proposal for Array.prototype.findRight

Noble idea using iterators, but few complaints:

  1. There's already some long-established precedent in the objects themselves: reduceRight and lastIndexOf.
  2. It's much lower overhead during execution as the engine doesn't need to figure out if it can elide every single object allocation in that. (And that would be a very complicated process - they don't even elide the intermediate array of array.filter(foo).map(bar) currently.)
  3. That's a...lot of typing just to do a reverse find when a normal find is extremely straightforward.
2 Likes

Are you perhaps thinking of https://tc39.es/ecma262/#sec-array.prototype.findlast ?

This discussion pre-dated that method's addition.

Actually that proposal came from this very discussion, i just didn’t see the entire thread in my email :-)

1 Like