mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 02:17:50 +00:00
cache is string and toString to improve performance
This commit is contained in:
@@ -478,8 +478,9 @@
|
|||||||
// Define the isArray, isDate, isFunction, isNumber, isRegExp, and
|
// Define the isArray, isDate, isFunction, isNumber, isRegExp, and
|
||||||
// isString functions based on their toString identifiers.
|
// isString functions based on their toString identifiers.
|
||||||
_.each(['Array', 'Date', 'Function', 'Number', 'RegExp', 'String'], function(type) {
|
_.each(['Array', 'Date', 'Function', 'Number', 'RegExp', 'String'], function(type) {
|
||||||
|
var toString = Object.prototype.toString, typeString = '[object ' + type + ']';
|
||||||
_['is' + type] = function(obj) {
|
_['is' + type] = function(obj) {
|
||||||
return Object.prototype.toString.call(obj) == '[object ' + type + ']';
|
return toString.call(obj) == typeString;
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user