diff --git a/underscore.js b/underscore.js index 1efa346b5..d36e07552 100644 --- a/underscore.js +++ b/underscore.js @@ -1110,11 +1110,6 @@ // Internal recursive comparison function for `isEqual`. var eq = function(a, b, aStack, bStack) { - // Identical objects are equal. `0 === -0`, but they aren't identical. - // See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal). - if (a === b) return a !== 0 || 1 / a === 1 / b; - // A strict comparison is necessary because `null == undefined`. - if (a == null || b == null) return a === b; // Unwrap any wrapped objects. if (a instanceof _) a = a._wrapped; if (b instanceof _) b = b._wrapped; @@ -1203,7 +1198,13 @@ // Perform a deep comparison to check if two objects are equal. _.isEqual = function(a, b) { - return eq(a, b); + // Identical objects are equal. `0 === -0`, but they aren't identical. + // See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal). + if (a === b) return a !== 0 || 1 / a === 1 / b; + var typeA = typeof a; + if( typeA != typeof b ) return false; + if( typeA == 'object' ) return a && b ? eq( a, b ) : a === b; + return a != a ? b != b : a === b; }; // Is a given array, string, or object empty?