The difference between operators == and === in JavaScript

273 views Asked by At

Everyone who come across comparison of objects in JavaScript struggle a lot with this topic because this syntax(===) is not represented in any other popular languages. They only have == and that’s it.

The problem is that I can’t really understand the difference between === and == and the purpose of it. We don’t have anything like that in any other popular languages like python, Java or C++.

I would like to clearly understand the pros and cons of using === in my code if you have any useful articles or other pieces of information please share.

1

There are 1 answers

0
Andrew Corrigan On

Basically, the only real difference is that === includes the type in the comparison; whereas == is just the value.

"6" == 6

Would be true, while:

"6" === 6

Would be false