mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 18:17:48 +00:00
Cleanup NaN handling in baseIndexOf and _.lastINdexOf.
This commit is contained in:
@@ -351,11 +351,11 @@
|
|||||||
function baseIndexOf(array, value, fromIndex) {
|
function baseIndexOf(array, value, fromIndex) {
|
||||||
var index = (fromIndex || 0) - 1,
|
var index = (fromIndex || 0) - 1,
|
||||||
length = array ? array.length : 0,
|
length = array ? array.length : 0,
|
||||||
nans = value !== value;
|
isReflexive = value === value;
|
||||||
|
|
||||||
while (++index < length) {
|
while (++index < length) {
|
||||||
var other = array[index];
|
var other = array[index];
|
||||||
if (other === value || (nans && other !== other)) {
|
if ((isReflexive ? other === value : other !== other)) {
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3731,10 +3731,10 @@
|
|||||||
index = sortedLastIndex(array, value) - 1;
|
index = sortedLastIndex(array, value) - 1;
|
||||||
return (length && array[index] === value) ? index : -1;
|
return (length && array[index] === value) ? index : -1;
|
||||||
}
|
}
|
||||||
var nans = value !== value;
|
var isReflexive = value === value;
|
||||||
while (index--) {
|
while (index--) {
|
||||||
var other = array[index];
|
var other = array[index];
|
||||||
if (other === value || (nans && other !== other)) {
|
if ((isReflexive ? other === value : other !== other)) {
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user