* Gets the index at which the first occurrence of `value` is found in `array` * using `SameValueZero` for equality comparisons. If `fromIndex` is negative, * it is used as the offset from the end of `array`. If `array` is sorted * providing `true` for `fromIndex` performs a faster bin
(array, value, fromIndex)
| 6509 | * // => 2 |
| 6510 | */ |
| 6511 | function indexOf(array, value, fromIndex) { |
| 6512 | var length = array ? array.length : 0; |
| 6513 | if (!length) { |
| 6514 | return -1; |
| 6515 | } |
| 6516 | if (typeof fromIndex == 'number') { |
| 6517 | fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : fromIndex; |
| 6518 | } else if (fromIndex) { |
| 6519 | var index = binaryIndex(array, value), |
| 6520 | other = array[index]; |
| 6521 | |
| 6522 | if (value === value ? (value === other) : (other !== other)) { |
| 6523 | return index; |
| 6524 | } |
| 6525 | return -1; |
| 6526 | } |
| 6527 | return baseIndexOf(array, value, fromIndex || 0); |
| 6528 | } |
| 6529 | |
| 6530 | /** |
| 6531 | * Gets all but the last element of `array`. |
no test coverage detected