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.
The index to search from.
Returns the index of the matched value, else -1.
-1
5.6.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
indexOf
except that it iterates over elements ofarray
from right to left.