diff --git a/lib/assert.js b/lib/assert.js index 6e4b9effbe5549..e120a981346640 100644 --- a/lib/assert.js +++ b/lib/assert.js @@ -178,7 +178,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 c240d1a33efd9f..068950a33d3c39 100644 --- a/test/parallel/test-assert-deep.js +++ b/test/parallel/test-assert-deep.js @@ -404,4 +404,7 @@ assertOnlyDeepEqual( assertDeepAndStrictEqual(m3, m4); } +assertDeepAndStrictEqual([1, , , 3], [1, , , 3]); +assertOnlyDeepEqual([1, , , 3], [1, , , 3, , , ]); + /* eslint-enable */