This method is like indexOf except that it iterates over elements of array from right to left.
indexOf
array
The array to inspect.
The value to search for.
Optional
The index to search from.
Returns the index of the matched value, else -1.
-1
0.1.0
lastIndexOf([1, 2, 1, 2], 2)// => 3// Search from the `fromIndex`.lastIndexOf([1, 2, 1, 2], 2, 2)// => 1 Copy
lastIndexOf([1, 2, 1, 2], 2)// => 3// Search from the `fromIndex`.lastIndexOf([1, 2, 1, 2], 2, 2)// => 1
This method is like
indexOfexcept that it iterates over elements ofarrayfrom right to left.