Avoid NaN use in isIndex.

This commit is contained in:
jdalton
2015-05-25 12:19:00 -07:00
parent d33c487b29
commit c1948f10a2

View File

@@ -4224,7 +4224,7 @@
* @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
*/
function isIndex(value, length) {
value = (typeof value == 'number' || reIsUint.test(value)) ? +value : NaN;
value = (typeof value == 'number' || reIsUint.test(value)) ? +value : -1;
length = length == null ? MAX_SAFE_INTEGER : length;
return value > -1 && value % 1 == 0 && value < length;
}