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.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
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.
Exactly. Also, if you reverse the array using
Array.prototype.reverse
, you're modifiying the original array. I've learned that the hard way.