Which operator checks both value and type equality in JavaScript?

The story behind the answer

The operator that checks both value and type equality in JavaScript is `===`, called the strict equality operator.

Unlike `==`, which may convert operands before comparing them, `===` returns `true` only when the operands have compatible types and equal values. Thus, `5 === 5` is true, while `5 === "5"` is false. This avoids many surprising results caused by implicit type conversion.

Strict equality has a few important edge cases. Objects are equal only when both references point to the same object, so two separately created objects with identical properties are not strictly equal. Also, `NaN === NaN` is false, while positive and negative zero compare as equal. Developers needing different behavior for these cases can use `Object.is()`.

The related `!==` operator checks strict inequality. The double-equals operator `==` is not interchangeable: for example, `"1" == 1` is true because conversion occurs, but `"1" === 1` is false.

Source: Wikipedia · fact-checked Aug. 2026

Add question to a list

Choose a list to keep this question in: