Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80742 views
1
var indexOfNaN = require('./indexOfNaN');
2
3
/**
4
* The base implementation of `_.indexOf` without support for binary searches.
5
*
6
* @private
7
* @param {Array} array The array to search.
8
* @param {*} value The value to search for.
9
* @param {number} fromIndex The index to search from.
10
* @returns {number} Returns the index of the matched value, else `-1`.
11
*/
12
function baseIndexOf(array, value, fromIndex) {
13
if (value !== value) {
14
return indexOfNaN(array, fromIndex);
15
}
16
var index = fromIndex - 1,
17
length = array.length;
18
19
while (++index < length) {
20
if (array[index] === value) {
21
return index;
22
}
23
}
24
return -1;
25
}
26
27
module.exports = baseIndexOf;
28
29