mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 01:57:50 +00:00
Optimize _.isNumber and _.isString. [closes #126]
Former-commit-id: 633dfe2e9c2c0ff7e54d5bbb4bf95f9adcca83c4
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user