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/6.0/#sec-samevaluezero)
10 * for equality comparisons. If `fromIndex` is negative, it's used as the offset
11 * from the end of `array`.
16 * @param {Array} array The array to search.
17 * @param {*} value The value to search for.
18 * @param {number} [fromIndex=0] The index to search from.
19 * @returns {number} Returns the index of the matched value, else `-1`.
22 * _.indexOf([1, 2, 1, 2], 2);
25 * // Search from the `fromIndex`.
26 * _.indexOf([1, 2, 1, 2], 2, 2);
29 function indexOf(array, value, fromIndex) {
30 var length = array ? array.length : 0;
34 fromIndex = toInteger(fromIndex);
36 fromIndex = nativeMax(length + fromIndex, 0);
38 return baseIndexOf(array, value, fromIndex);
41 module.exports = indexOf;