Skip to content


What's the difference between and the triple equals operator in JavaScript?

If you want to check equality in JavaScript, there are two comparison operators, which are explained in depth in a previous article.

Very briefly, the double equals operator (==) only compares value whereas the triple equals operator (===) compares both value and type. But there is also a third option,, which behaves the same as the triple equals operator with the exception of NaN and +0 and -0.

Here are some examples for additional clarity:

{} === {}; // false{}, {}); // false

1 === 1; // true, 1); // true

+0 === -0; // true, -0); // false

NaN === NaN; // false, NaN); // true

More like this

Start typing a keyphrase to see matching snippets.