I know that there are many quirks with the equality operator (==
). For example, following are all true...
null == undefined
1 == '1'
true == 1
false == ''
In all the above cases, using identity operator (===
) would have returned the (strictly) correct answer.
But, when I just want to compare simpler things that do not suffer from quirks, why shouldn't I use the equality operator. For example...
typeof x == 'number'
str == 'something'
So, my question is; why does the equality operator have such a derogatory status, when in fact it's useful in some situations.