diff --git a/test/objects.js b/test/objects.js index 6fc60f1e4..95e5ab829 100644 --- a/test/objects.js +++ b/test/objects.js @@ -318,14 +318,14 @@ $(document).ready(function() { parent.iElement = document.createElement('div');\ parent.iArguments = (function(){ return arguments; })(1, 2, 3);\ parent.iArray = [1, 2, 3];\ - parent.iString = 'hello';\ - parent.iNumber = 100;\ + parent.iString = new String('hello');\ + parent.iNumber = new Number(100);\ parent.iFunction = (function(){});\ parent.iDate = new Date();\ parent.iRegExp = /hi/;\ parent.iNaN = NaN;\ parent.iNull = null;\ - parent.iBoolean = false;\ + parent.iBoolean = new Boolean(false);\ parent.iUndefined = undefined;\ " ); diff --git a/underscore.js b/underscore.js index 46f0ef685..e2a2fb260 100644 --- a/underscore.js +++ b/underscore.js @@ -614,7 +614,7 @@ var isNumberA = _.isNumber(a), isNumberB = _.isNumber(b); if (isNumberA || isNumberB) return isNumberA && isNumberB && +a == +b; // Compare boolean objects by value. The value of `true` is 1; the value of `false` is 0. - var isBooleanA = toString.call(a) == '[object Boolean]', isBooleanB = toString.call(b) == '[object Boolean]'; + var isBooleanA = _.isBoolean(a), isBooleanB = _.isBoolean(b); if (isBooleanA || isBooleanB) return isBooleanA && isBooleanB && +a == +b; // Compare dates by their millisecond values. var isDateA = _.isDate(a), isDateB = _.isDate(b); @@ -738,7 +738,7 @@ // Is a given value a boolean? _.isBoolean = function(obj) { - return obj === true || obj === false; + return obj === true || obj === false || typeof obj == 'object' && toString.call(obj) == '[object Boolean]'; }; // Is a given value a date?