4.17.11
3.10.1
2.4.2
1.3.1
_.indexOf(array, value, [fromIndex=0])
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
.
Since
0.1.0
Arguments
argument
array
value
[fromIndex=0]
type
Array
*
number
description
The array to inspect.
The value to search for.
The index to search from.
Returns
(array)
Example
_.indexOf([1, 2, 1, 2], 2);
// => 1
// Search from the `fromIndex`.
_.indexOf([1, 2, 1, 2], 2, 2);
// => 3
_.indexOf([1, 2, 1, 2], 2);
// => 1
// Search from the `fromIndex`.
_.indexOf([1, 2, 1, 2], 2, 2);
// => 3