diff --git a/lib/assert.js b/lib/assert.js index bdc2fcf5a8..70327467ab 100644 --- a/lib/assert.js +++ b/lib/assert.js @@ -180,7 +180,14 @@ function strictDeepEqual(actual, expected) { if (Object.getPrototypeOf(actual) !== Object.getPrototypeOf(expected)) { return false; } - if (isObjectOrArrayTag(actualTag)) { + if (actualTag === '[object Array]') { + // Check for sparse arrays and general fast path + if (actual.length !== expected.length) + return false; + // Skip testing the part below and continue in the callee function. + return; + } + if (actualTag === '[object Object]') { // Skip testing the part below and continue in the callee function. return; } diff --git a/test/parallel/test-assert-deep.js b/test/parallel/test-assert-deep.js index 08b0b80d9d..e13973711c 100644 --- a/test/parallel/test-assert-deep.js +++ b/test/parallel/test-assert-deep.js @@ -466,4 +466,7 @@ assertOnlyDeepEqual( assertDeepAndStrictEqual(m3, m4); } +assertDeepAndStrictEqual([1, , , 3], [1, , , 3]); +assertOnlyDeepEqual([1, , , 3], [1, , , 3, , , ]); + /* eslint-enable */