logo

Difference between == vs === in JavaScript

May 14, 2021

In JavaScript, we can use two operators to check for comparisons. They are == and ===.

Strict equality will check if two values are the same type, and their values are equal.

The == will compare for equality after doing any necessary type conversion.

true == 1; // true
true === 1; // false
"" == "0"; // false
0 == ""; // true
null == undefined; // true
null === undefined; // false