== or === What's the difference?
If you're new to Javascript, you will find code where === is used while in other languages only == is there and you might be curious why is that, let's learn about the differences and their usages in this article.
If you've got a basic understanding of programming you would know it's an equality operator which returns a boolean value when two operands are compared. If we compare 207 and "207" using both the operators, 207 == "207" will return True while 207 === "207" will return False because in Javascript when we compare using == it'll convert the types of the operand on both sides while === will take both the operands as it is without changing their datatypes and compare it strictly, that's why it is called strict equality operator.
It's always better to use the strict equality operator to avoid any bugs and issues. The only time I find the equality operator to be useful is when you're comparing Undefined and Null, what's the difference between these two let's find out in the next article.
Thanks for reading, will meet you in the next article.
Subscribe to my newsletter
Read articles from Jassahib Singh directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by