MCPcopy
hub / github.com/lodash/lodash / lastIndexOf

Function lastIndexOf

lodash.js:7730–7743  ·  view source on GitHub ↗

* This method is like `_.indexOf` except that it iterates over elements of * `array` from right to left. * * @static * @memberOf _ * @since 0.1.0 * @category Array * @param {Array} array The array to inspect. * @param {*} value The value to search for. *

(array, value, fromIndex)

Source from the content-addressed store, hash-verified

7728 * // => 1
7729 */
7730 function lastIndexOf(array, value, fromIndex) {
7731 var length = array == null ? 0 : array.length;
7732 if (!length) {
7733 return -1;
7734 }
7735 var index = length;
7736 if (fromIndex !== undefined) {
7737 index = toInteger(fromIndex);
7738 index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1);
7739 }
7740 return value === value
7741 ? strictLastIndexOf(array, value, index)
7742 : baseFindIndex(array, baseIsNaN, index, true);
7743 }
7744
7745 /**
7746 * Gets the element at index `n` of `array`. If `n` is negative, the nth

Callers

nothing calls this directly

Calls 3

toIntegerFunction · 0.85
strictLastIndexOfFunction · 0.85
baseFindIndexFunction · 0.85

Tested by

no test coverage detected