Cleanup NaN handling in baseIndexOf and _.lastINdexOf.

This commit is contained in:
John-David Dalton
2014-08-01 11:27:37 -07:00
parent 2aa94301a8
commit 4dc41749fb

View File

@@ -351,11 +351,11 @@
function baseIndexOf(array, value, fromIndex) {
var index = (fromIndex || 0) - 1,
length = array ? array.length : 0,
nans = value !== value;
isReflexive = value === value;
while (++index < length) {
var other = array[index];
if (other === value || (nans && other !== other)) {
if ((isReflexive ? other === value : other !== other)) {
return index;
}
}
@@ -3731,10 +3731,10 @@
index = sortedLastIndex(array, value) - 1;
return (length && array[index] === value) ? index : -1;
}
var nans = value !== value;
var isReflexive = value === value;
while (index--) {
var other = array[index];
if (other === value || (nans && other !== other)) {
if ((isReflexive ? other === value : other !== other)) {
return index;
}
}