Fork me on GitHub

JSLint Error Explanations

JSLint will hurt your feelings. It's time to make them better!


Expected a conditional expression and instead saw an assignment.

When do I get this error?

As of July 2013, JSLint has removed this warning and instead now issues the "Unexpected assignment expression" warning. More details may be found on the page for that message.

JSLint (prior to July 2013) and JHint will throw this error when a clause exists in a while, for, or if that contains an ambiguous assignment operator where a comparison operator could exist:

The above example is clearly a bug, and the fix is to simply use a comparison operator instead of an assignment:

There are also legitimate situations where you can get this error:

In this case, you can force the expression to a conditional:

This error can also show up if you don't initialize a loop variable to a value:

The fix for this is simple, just set the loop iterator to a value in the beginning of the loop:


comments powered by Disqus