I have always believed you use continue as follows:
var i;
for (i = 0; i < 10; i++) {
if(i%2===0) {
continue;
}
}
Or
var i, myloop;
myloop: for (i = 0; i < 10; i++) {
if(i%2===0) {
continue myloop;
}
}
But when I run these two snippets of code through JSLint, I get the error:
Problem at line 5 character 5: Unexpected 'continue'.
continue;
What am I doing wrong? What is the correct usage?
var iup to even get that far, right? Improving your code is JSLint's secondary concern, enforcing Doug Crockford's personal opinions about JavaScript being its first. There's always JSHint if you want a less opinionated alternative.