I would suggest that there is no problem with using ==
, but to understand when and why to use it (i.e. use ===
as a rule, and ==
when it serves a purpose). Essentially, ==
just gives you shorthand notation - instead of doing something like
if (vble === 0 || vble === "" || vble === null || vble === undefined || vble === false) ...
It's much easier to just write
if (vble == false) ...
(Or even easier to write)
if (!vble) ...
Of course there are more examples than just looking for "truthy" or "falsey" values.
Really, you just need to understand when and why to use ==
and ===
, I don't see any reason why not to use ==
where it fits better...
Another example is using this shorthand to allow shorthand method calls:
function func(boolOptionNotCommonlyUsed) {
if (boolOptionNotCommonlyUsed) { //equiv to boolOptionNotCommonlyUsed == true
//do something we rarely do
}
//do whatever func usually does
}
func(); //we rarely use boolOptionNotCommonlyUsed, so allow calling without "false" as an arg