Gets the index at which the first occurrence of value is found in array using SameValueZero for equality comparisons. If fromIndex is negative, it's used as the offset from the end of array.
value
array
SameValueZero
fromIndex
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
5.5.1
indexOf([1, 2, 1, 2], 2)// => 1// Search from the `fromIndex`.indexOf([1, 2, 1, 2], 2, 2)// => 3 Copy
indexOf([1, 2, 1, 2], 2)// => 1// Search from the `fromIndex`.indexOf([1, 2, 1, 2], 2, 2)// => 3
Gets the index at which the first occurrence of
value
is found inarray
usingSameValueZero
for equality comparisons. IffromIndex
is negative, it's used as the offset from the end ofarray
.