Possible Duplicate:
Javascript === vs == : Does it matter which “equal” operator I use?
In Douglas Crockford's book Javascript: The Good Parts, it is recommended to not use ==
at all, due to hard to memorized rules. Do advanced or seasoned Javascript programmers really not use ==
or !=
?
If so, then I guess we will be using ===
and !==
, but then how do we use them effectively? Is the most common case comparing a string with number, so we can always do
if (Number(s) == 3) { ... } // s is a string
Can Number(s)
work in most browsers? And what are the other common cases to use with ===
?