freecoding.school100% FREE · NO SIGNUP
Script SpringsISSUE #17 of 29

operators · comparison · == vs ===

SparkyVSNaN the Trickster
Sparky saysUse === (strict equality) — it checks type and value; == coerces types and causes bugs.

=== compares without type conversion: 1 === "1" is false. == coerces first, leading to surprises (0 == "", null == undefined). The rule: always use === and !==. Reach for == only deliberately, e.g. x == null to catch both null and undefined.

Power-ups you unlock

NaN the Trickster attacks — common mistakes

Boss battleCompare 1 === "1" vs 1 == "1" and explain the difference.

Example code

<!doctype html><html><head><meta charset="utf-8"></head>
<body style="background:#06040d;color:#e6e0ff;font-family:monospace;padding:20px"><pre id="o"></pre>
<script>const o=['1 === "1" → '+(1==='1'), '1 == "1" → '+(1=='1'), '0 == "" → '+(0=='')];
document.getElementById('o').textContent=o.join('\n');</script></body></html>
▶ Open the interactive comic issue
‹ Operators · Assignment · += · -= · ??=Operators · Logical · && · || · ! ›