_.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
array
(Array): The array to inspect.value
(*): The value to search for.[fromIndex=0]
(number): The index to search from.
Returns
(number): Returns the index of the matched value, else -1
.
Example
_.indexOf([1, 2, 1, 2], 2);// => 1// Search from the `fromIndex`._.indexOf([1, 2, 1, 2], 2, 2);// => 3
当前内容版权归 lodash.com 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 lodash.com .