1 var baseIndexOf = require('./_baseIndexOf'),
2 toInteger = require('./toInteger');
4 /* Built-in method references for those with the same name as other `lodash` methods. */
5 var nativeMax = Math.max;
8 * Gets the index at which the first occurrence of `value` is found in `array`
9 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
10 * for equality comparisons. If `fromIndex` is negative, it's used as the
11 * offset from the end of `array`.
17 * @param {Array} array The array to inspect.
18 * @param {*} value The value to search for.
19 * @param {number} [fromIndex=0] The index to search from.
20 * @returns {number} Returns the index of the matched value, else `-1`.
23 * _.indexOf([1, 2, 1, 2], 2);
26 * // Search from the `fromIndex`.
27 * _.indexOf([1, 2, 1, 2], 2, 2);
30 function indexOf(array, value, fromIndex) {
31 var length = array == null ? 0 : array.length;
35 var index = fromIndex == null ? 0 : toInteger(fromIndex);
37 index = nativeMax(length + index, 0);
39 return baseIndexOf(array, value, index);
42 module.exports = indexOf;