In JavaScript there are two types of equality operator, the === and the !== , sorry I forgot to mention their evil twin == and != .
tsdr; (too short didn’t read) Use three equals unless you fully understand the conversions that take place for two-equals.
Basically what the triple equal (===) compares is if the value is equal and if the type is equal.
Lets look at an example below.
The reason for the === operator to return false is due to the fact that it does not do type coercion, but the double == does type coercion and implicitly tries to convert the value before comparing.
Some additional examples:
I hope the examples above give you the reason to stop using == and != since it convert things for you during comparison. So start using the triple === and !== .
Below are two tables that show the equality of == and === provide by http://dorey.github.io/JavaScript-Equality-Table/

x === y
Leave A Comment