Let’s start with a simple rule: the normal equality operators == and != are so problematic that you should always use strict equality (=== and !==). Some people say that there are exceptions to this rule, I disagree . Keeping this rule in mind, we can now take a look at what is strange about ==, without burdening our minds unnecessarily.
The “normal” equality operator (==) has many quirks. While it is forgiving, it does not adhere to the typical rules of truthy and falsy (see quirk 1):
> 0 == false // OK true > 1 == true // OK true > 2 == true // not OK false > '' == false // OK true > '1' == true // OK true > '2' == true // not OK falseApart from that, it lets you compare values that aren’t really comparable:
If you are still interested in finding out how exactly == works, you can read up on it here: . With strict equality (===), values of different types are never equal , which means that all of the above problems go away.