From 6554c6d9762d71c056d573fabf0ead967a75b308 Mon Sep 17 00:00:00 2001 From: Noah Sloan Date: Tue, 8 Dec 2009 15:57:04 -0600 Subject: [PATCH] have to define isNumber before _.each will work in IE --- underscore.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/underscore.js b/underscore.js index da40afaa8..834ecac9a 100644 --- a/underscore.js +++ b/underscore.js @@ -475,10 +475,15 @@ _.isUndefined = function(obj) { return typeof obj == 'undefined'; }; + + // have to define isNumber before _.each will work in IE + _.isNumber = function(obj) { + return Object.prototype.toString == '[object Number]'; + }; - // Define the isArray, isDate, isFunction, isNumber, isRegExp, and + // Define the isArray, isDate, isFunction, isRegExp, and // isString functions based on their toString identifiers. - _.each(['Array', 'Date', 'Function', 'Number', 'RegExp', 'String'], function(type) { + _.each(['Array', 'Date', 'Function', 'RegExp', 'String'], function(type) { var toString = Object.prototype.toString, typeString = '[object ' + type + ']'; _['is' + type] = function(obj) { return toString.call(obj) == typeString;