From 4dc41749fb3d91e464a01cb18f843a32d23ef325 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Fri, 1 Aug 2014 11:27:37 -0700 Subject: [PATCH] Cleanup `NaN` handling in `baseIndexOf` and `_.lastINdexOf`. --- lodash.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lodash.js b/lodash.js index 53987c991..8e9a426e5 100644 --- a/lodash.js +++ b/lodash.js @@ -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; } }