From 4dd56a39f1f1c0e98b223b611c3a869775177c68 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Fri, 30 Nov 2018 10:21:14 +0100 Subject: assert,util: fix sparse array comparison MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Comparing sparse arrays did not work properly. That is fixed and tests were added to verify that everything works as expected. This had an impact on `util.isDeepStrictEqual()` and `assert.deepStrictEqual()` and their counterpart `assert.notDeepStrictEqual()`. PR-URL: https://github.com/nodejs/node/pull/24749 Reviewed-By: Anna Henningsen Reviewed-By: Michaƫl Zasso --- lib/internal/util/comparisons.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'lib/internal/util/comparisons.js') diff --git a/lib/internal/util/comparisons.js b/lib/internal/util/comparisons.js index 43a8921f65..905946fdee 100644 --- a/lib/internal/util/comparisons.js +++ b/lib/internal/util/comparisons.js @@ -558,11 +558,10 @@ function objEquiv(a, b, strict, keys, memos, iterationType) { } else { // Array is sparse. const keysA = objectKeys(a); - i++; for (; i < keysA.length; i++) { const key = keysA[i]; if (!hasOwnProperty(b, key) || - !innerDeepEqual(a[key], b[i], strict, memos)) { + !innerDeepEqual(a[key], b[key], strict, memos)) { return false; } } -- cgit v1.2.3