Optimize _.isNumber and _.isString. [closes #126]

Former-commit-id: 633dfe2e9c2c0ff7e54d5bbb4bf95f9adcca83c4
This commit is contained in:
John-David Dalton
2012-11-24 09:46:20 -06:00
parent faf018a097
commit d2d1d42d0f
4 changed files with 67 additions and 67 deletions

View File

@@ -1482,7 +1482,7 @@
function isNaN(value) {
// `NaN` as a primitive is the only value that is not equal to itself
// (perform the [[Class]] check first to avoid errors with some host objects in IE)
return toString.call(value) == numberClass && value != +value
return isNumber(value) && value != +value
}
/**
@@ -1519,7 +1519,7 @@
* // => true
*/
function isNumber(value) {
return toString.call(value) == numberClass;
return typeof value == 'number' || toString.call(value) == numberClass;
}
/**
@@ -1589,7 +1589,7 @@
* // => true
*/
function isString(value) {
return toString.call(value) == stringClass;
return typeof value == 'string' || toString.call(value) == stringClass;
}
/**