From e21b346cbf265278145c253d4f5c784858ccfc3e Mon Sep 17 00:00:00 2001 From: Kit Goncharov Date: Tue, 12 Jul 2011 19:54:56 -0600 Subject: [PATCH] `_.isEqual`: Compare object types rather than `[[Class]]` names. --- underscore.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/underscore.js b/underscore.js index 6bc1ed9e4..0611f8e1d 100644 --- a/underscore.js +++ b/underscore.js @@ -600,9 +600,9 @@ if (a === b) return true; // A strict comparison is necessary because `null == undefined`. if (a == null) return a === b; - // Compare `[[Class]]` names. - var className = toString.call(a); - if (className != toString.call(b)) return false; + // Compare object types. + var typeA = typeof a; + if (typeA != typeof b) return false; // Compare functions by reference. if (_.isFunction(a)) return _.isFunction(b) && a == b; // Compare strings, numbers, dates, and booleans by value. @@ -616,7 +616,7 @@ a.multiline == b.multiline && a.ignoreCase == b.ignoreCase; // Recursively compare objects and arrays. - if (typeof a != 'object') return false; + if (typeA != 'object') return false; // Unwrap any wrapped objects. if (a._chain) a = a._wrapped; if (b._chain) b = b._wrapped;