DEV Community

Discussion on: Introducing `findLast` and `findLastIndex`

Collapse
 
nicozerpa profile image
Nico Zerpa (he/him)

I had to find the last occurrence in an array just minutes ago, lol
I agree with you, there's never too many array utility methods.

The one that comes to mind for me is to reverse the array and then use find. But this isn't performant for large arrays, it requires more steps than it should, and it doesn't work well if there aren't any matching elements in the array.

Exactly. Also, if you reverse the array using Array.prototype.reverse, you're modifiying the original array. I've learned that the hard way.