Mar
25
JSlint may just occasionally save you from yourself.
The following code is clearly nonsense. The clause will never evaluate to true, and your alert will never be shown:
if (1 === 0) {
alert("hello");
}
But you’ll also get the JSLint message where the clause does evaluate to true:
if (1 === 1) {
alert("hello");
}
In general, this message will appear when both sides of the clause are literal values or if they are identical, for example:
if (myVar === myVar) {
alert("hello");
}
We are not just limited to ‘if’ clauses, either. ‘while’ tests will also yield this error.
A Guide To JSLint Messages
This article is one of a series on the error and warning messages produced by JSLint.
[...] [...]