Using the double equality operator forces Javascript to do type coercion.
In other words, if you execute x == y , if x and y not of the same type, JavaScript will distinguish one value before comparison, for example, if you compare a string and a number, the string is always inserted into the number, and then compared
For this reason, many comparisons of mixed types in JavaScript can produce results that may be unexpected or inconsistent.
If you want to do comparisons in JavaScript, it's usually better to use the triple equality operator === rather than double. This does not lead to type coercion; instead, if the types are different, it returns false. This is most often what you need.
You should use only two times if you are absolutely sure that you need it.
Spudley
source share