MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / indexOf

Function indexOf

lib/web/jshint.js:6511–6528  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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`.

Callers 5

baseDifferenceFunction · 0.70
baseUniqFunction · 0.70
intersectionFunction · 0.70
pullFunction · 0.70
findNthSubstringMethod · 0.50

Calls 2

binaryIndexFunction · 0.85
baseIndexOfFunction · 0.85

Tested by

no test coverage detected