Strict equality (===)
Compares two values for equality without type coercion.
Syntax
a === b
a !== b
Returns
boolean — `true` if the operands have the same type and value.
Examples
console.log(1 === 1);
console.log(1 === "1");
Output
true
false
console.log(null === undefined);
Output
false
const a = {};
console.log(a === a);
console.log({} === {});
Output
true
false
Notes
- No type coercion: operands of different types are never strictly
equal.
- Objects compare by reference identity, not structure.
- `NaN === NaN` is `false`; use `Number.isNaN()` or `Object.is()`.
Browser & runtime support
| Environment | Since version |
|---|---|
| chrome | 1.0 |
| firefox | 1.0 |
| safari | 1.0 |
| edge | 12 |
| node | 0.10 |