Unexpected 'continue'

asifg picture asifg · May 20, 2011 · Viewed 12.1k times · Source

I have:

while (i < l) {
   if (one === two) { continue; }
   i++;
}

But JSLint says:

Problem at line 1 character 20: Unexpected 'continue'.

if (one === two) { continue; }

What mistake did I make? How should my code really look?

Answer

Quentin picture Quentin · May 20, 2011

From the JSLint docs:

continue Statement

Avoid use of the continue statement. It tends to obscure the control flow of the function.

So take it out entirely if you want to conform to the conventions that JSLint follows.