From 8c7fcb7781c89cc2d41c415ff5fbb755bbd4000c Mon Sep 17 00:00:00 2001 From: Noah Sloan Date: Tue, 8 Dec 2009 14:11:28 -0600 Subject: [PATCH] cache is string and toString to improve performance --- underscore.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/underscore.js b/underscore.js index 51398635d..b94cc0f9b 100644 --- a/underscore.js +++ b/underscore.js @@ -478,8 +478,9 @@ // Define the isArray, isDate, isFunction, isNumber, isRegExp, and // isString functions based on their toString identifiers. _.each(['Array', 'Date', 'Function', 'Number', 'RegExp', 'String'], function(type) { + var toString = Object.prototype.toString, typeString = '[object ' + type + ']'; _['is' + type] = function(obj) { - return Object.prototype.toString.call(obj) == '[object ' + type + ']'; + return toString.call(obj) == typeString; }; });