From f64b8e822266200af00fd44c57a1757181eb0f28 Mon Sep 17 00:00:00 2001 From: Nicolas DUBIEN Date: Wed, 30 Oct 2019 14:38:39 +0100 Subject: [PATCH] Wrong value for _.isEqual(0, new Number(Number.MIN_VALUE)) --- test/objects.js | 1 + underscore.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/test/objects.js b/test/objects.js index 8e86aac27..356b54eb9 100644 --- a/test/objects.js +++ b/test/objects.js @@ -330,6 +330,7 @@ assert.ok(!_.isEqual(-0, 0), 'Commutative equality is implemented for `0` and `-0`'); assert.ok(!_.isEqual(null, void 0), '`null` is not equal to `undefined`'); assert.ok(!_.isEqual(void 0, null), 'Commutative equality is implemented for `null` and `undefined`'); + assert.ok(!_.isEqual(0, new Number(Number.MIN_VALUE)), '`0` is not equal to `new Number(Number.MIN_VALUE)`'); // String object and primitive comparisons. assert.ok(_.isEqual('Curly', 'Curly'), 'Identical string primitives are equal'); diff --git a/underscore.js b/underscore.js index 8219dc508..46acc5a70 100644 --- a/underscore.js +++ b/underscore.js @@ -1223,7 +1223,7 @@ // Object(NaN) is equivalent to NaN. if (+a !== +a) return +b !== +b; // An `egal` comparison is performed for other numeric values. - return +a === 0 ? 1 / +a === 1 / b : +a === +b; + return +a === 0 && +b === 0 ? 1 / +a === 1 / b : +a === +b; case '[object Date]': case '[object Boolean]': // Coerce dates and booleans to numeric primitive values. Dates are compared by their