Create isEqual that correctly handles NaN === NaN, -0 vs +0, Dates, RegExps, Arrays, plain objects, and circular references.
Skip to solutionKEEP THE
hardDSA
Implement deepEqual(a, b) handling NaN, -0, Dates, RegExp & circular refs
586 views
01
Understand the problem
deep-equalNaN-0edge-cases
02
Attempt it yourself
Sketch your approach before reading the solution — that's what interviews test.
Nudge consolestandby
Stuck? Beam a request up — the console returns a conceptual nudge that guides your logic without spoiling the implementation.
03
Study the solution
Approach: Fast paths for SameValue (Object.is distinguishes -0/NaN), then type checks, then structural recursion with WeakMap for circular tracking.
function deepEqual(a, b, seen = new WeakMap()) {
if (Object.is(a, b)) return true;
if (a == null || b == null || typeof a !== 'object' || typeof b !
Solution ready — 2 min read
Classified // press E to declassify
04
Join the discussion
Discussion (0)
Sign in to join the discussion.
No responses yet. Be the first to share what you think.
Transmission complete // awaiting log
KEEP THE
STREAK ALIVE.
Dossier 187 of 190 decoded in the JavaScript Coding track. One more won't hurt.