diff --git a/lib/internal/util/comparisons.js b/lib/internal/util/comparisons.js index 205d84f4840886..0596bd8b2a8b57 100644 --- a/lib/internal/util/comparisons.js +++ b/lib/internal/util/comparisons.js @@ -401,9 +401,7 @@ function mapMightHaveLoosePrim(a, b, prim, item, memo) { !innerDeepEqual(item, curB, false, memo)) { return false; } - const curA = a.get(altValue); - return curA === undefined && a.has(altValue) || - innerDeepEqual(item, curA, false, memo); + return !a.has(altValue) && innerDeepEqual(item, curB, false, memo); } function setEquiv(a, b, strict, memo) { diff --git a/test/parallel/test-assert-deep.js b/test/parallel/test-assert-deep.js index 45f4353ce6c577..36758682941046 100644 --- a/test/parallel/test-assert-deep.js +++ b/test/parallel/test-assert-deep.js @@ -380,6 +380,14 @@ assertOnlyDeepEqual( new Map([[1, {}]]), new Map([[true, {}]]) ); +assertOnlyDeepEqual( + new Map([[undefined, true]]), + new Map([[null, true]]) +); +assertNotDeepOrStrict( + new Map([[undefined, true]]), + new Map([[true, true]]) +); // GH-6416. Make sure circular refs don't throw. {