Skip to solution
easyPhone Screen

What is the difference between Object.is, ==, and ===?

521 views
01

Understand the problem

Question presented to candidate: "What is the actual difference between Object.is(a, b), a == b, and a === b? Walk me through where all three agree, and the specific cases where they disagree."

What a strong answer should cover:

  • == performs type coercion before comparing; === and Object.is never coerce types, so 1 === "1" and Object.is(1, "1") are both false while 1 == "1" is true.
  • === and Object.is agree on almost everything, EXCEPT exactly two IEEE-754 floating point edge cases: NaN and negative zero.
  • NaN === NaN is false (the famous exception), but Object.is(NaN, NaN) is true -- Object.is exists partly to give a correct way to test NaN equality without that gotcha.
  • 0 === -0 is true, but Object.is(0, -0) is false -- Object.is is actually STRICTER than === in this one specific case, not simply a safer alias for it.
  • None of the three perform structural/deep equality on objects or arrays -- two separately created array literals with identical contents are never equal under any of the three, since object comparison is always by reference.

Clarifying questions expected:

  • "Should I also cover Array.prototype.includes, since it uses a related but different algorithm called SameValueZero?"

Code / implementation expected: Yes -- a runnable truth table covering NaN, -0, type coercion, and reference equality.

equalityobject-iscoercion
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

Target Audience: Engineers preparing for JavaScript fundamentals and equality-semantics interview questions. Difficulty: Medium

How to read this doc: Concepts are explained in plain language first, then tagged with 📌 Interview term:. Every result below was actually run on Node.js v24.19.0 —

Solution ready — 2 min read

Classified // press E to declassify

04

Run the code

JSFull equality truth table: ==, ===, Object.is, and Array.includes (run directly)
05

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 22 of 165 decoded in the JavaScript track. One more won't hurt.

Back to track