In JavaScript there are two ways to test equality/inequality. We can use two equal signs (==) or three equal signs (===). For inequality, it is similar != and !==. So what’s the difference? The difference is type. For example…
If( 5 == ‘5’ ){}
This would return true because with a double equal sign, JavaScript converts types. The string of ‘5’ would be converted to a number and the values of each item would be compared. We can avoid this type conversion by using triple equals…
If( 5 === ‘5’ ){}
This one would return false because the triple equal signs tells JavaScript to not perform type conversion. Another way to think of it is that it compares not only the value like the double equal sign, but also the type.
Not equal works the same way. A single equal (!=) ignores type while double equals consider type (!==).
Happy Coding!
Clay Hess