Feature proposal

T.J. Crowder tj.crowder at farsightsoftware.com
Wed Jul 18 17:04:25 UTC 2018

On Wed, Jul 18, 2018 at 5:44 PM, Cyril Auburtin <cyril.auburtin at gmail.com>
> sorry you get 1, and need again to subtract the array length, `arr.length
> - 1` to get the final result 3

So you can't just use the passed-in third argument, and need:

let a = [7, 4, 6, 7, 12];
console.log(a.length - 1 - a.findIndex((_, i) => isPrime(a[a.length-1-i])));

Strikes me as a reasonable argument for adding `findLastIndex`. ;-) (And
perhaps `findLast`, since the same trick with `find` just won't work at

Prior art (looking for instance at the libs that inspired the array
additions in ES5 and ES2015):
* Lodash implements both `findLastIndex` and `findLast`).
* Underscore, PrototypeJS, and MooTools don't as far as I can see from the

-- T.J. Crowder
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20180718/5cd3df5c/attachment.html>

More information about the es-discuss mailing list