Comparison operators
Last updated: 2026-09-09
Comparison operators Comparison operators
Comparison operators return booleans. === (strict) is preferred; == (loose) should be avoided.
| Category | Operators |
|---|---|
| ES version | ES1 |
📝 Syntax
a === b; a !== b; a > b;
Returns:A boolean.
Mutates the original:No (returns a new value)
▶ Example
Edit the code, press Run, and see the result in the output panel:
Output:
false
true
true
true
false
⚠️ Warning Always use === not == — implicit coercion rules are hard to remember.
ℹ️ info NaN equals nothing — use Number.isNaN() to check.
🌐 Browser support
| Browser | |||||
|---|---|---|---|---|---|
| Comparison operators | ✓ v1 | ✓ v12 | ✓ v1 | ✓ v1 | ✓ v1 |
| Supported by all modern browsers | |||||
🏷️ Related Operators
💡 Related Cases
More case studies coming soon — check back later.
📚 Related Tutorials
❓ FAQ
Q=== vs ==?
A=== strict (no coercion); == loose (coerces). Always use ===.
QHow to check NaN?
ANumber.isNaN(value) — NaN === NaN is false.
Qnull == undefined?
AYes for == (special case); but null === undefined is false.