Recently I was running some of my code through JSLint when I came up with this error. The thing I think is funny about this error though is that it automatically assumes tha
JSLint is inherently more defensive than the Javascript syntax allows for.
From the JSLint documentation:
The
==and!=operators do type coercion before comparing. This is bad because it causes' \t\r\n' == 0to be true. This can mask type errors.When comparing to any of the following values, use the
===or!==operators (which do not do type coercion):0 '' undefined null false trueIf you only care that a value is truthy or falsy, then use the short form. Instead of
(foo != 0)just say
(foo)and instead of
(foo == 0)say
(!foo)The
===and!==operators are preferred.