Does it mutate 😱
Array.prototype.lastIndexOf
No mutation
Description
The lastIndexOf()
method of Array
instances returns the last index at which
a given element can be found in the array, or -1 if it is not present. The array is
searched backwards, starting at fromIndex
.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf
Example
const animals = ['Dodo', 'Tiger', 'Penguin', 'Dodo'];
console.log(animals.lastIndexOf('Dodo'));
// Expected output: 3
console.log(animals.lastIndexOf('Tiger'));
// Expected output: 1