diff --git a/build.js b/build.js index 2250ad28e..cbfcba81d 100755 --- a/build.js +++ b/build.js @@ -1732,6 +1732,9 @@ " (!b || (otherType != 'function' && otherType != 'object'))) {", ' return false;', ' }', + ' if (a == null || b == null) {', + ' return a === b;', + ' }', ' var className = toString.call(a),', ' otherClass = toString.call(b);', '', diff --git a/lodash.js b/lodash.js index c0b86b0df..7861b9810 100644 --- a/lodash.js +++ b/lodash.js @@ -1461,6 +1461,11 @@ (!b || (otherType != 'function' && otherType != 'object'))) { return false; } + // exit early for `null` and `undefined`, avoiding ES3's Function#call behavior + // http://es5.github.com/#x15.3.4.4 + if (a == null || b == null) { + return a === b; + } // compare [[Class]] names var className = toString.call(a), otherClass = toString.call(b);