Equality and Inequality Operators
Double equal sign (==) perform some conversion before comparing the actual value, while tripe equal sign (===) will directly compare the value without doing any conversion.
When we use double equal sign (== ), it performs type coercion.
It means that it takes two numbers or strings or two variables and then tries to make it into a similar type so that it can compare.
So here is an example, where we have declared a variable X with the value 55.
var X = 55; X == 55; X == "55";
You can see here in above result, when we performing X == 55 or X == “55” where 55 in quotes is string but it perform some conversion first convert the value into similar type, in this case, it converting type from string to number and then it showing output that its true.
And here is another example where we performing comparison rule with three equals sign like X === “55”. Here 55 treated as a string.
You can see in above output three equal sign (===) does not care about type version as well as the value and that’s why the output is false.
NOTE: you should always use === because it is much safer, it’s much more specific.
Assume X = 5
|X != 5||X is not equal to 5||False|
|X !== “5”||X is not equal to string 5||TRUE|