|
| JAVASCRIPT CONTINUE STATEMENT
The continue statement is used to only stop the code following the continue word from executing if a certain test condition is met, but further looping occurs until the loop ends naturally.
Example Without Continue:
i=0;
while(i < 10)
{
i++;
document.write(i + "<br>");
}
The above will output numbers 1 through to 10 and the loop ends naturally.
Example With Continue:
i=0;
while(i < 10)
{
i++;
if(i==4) continue;
document.write(i + "<br>");
}
The above will output numbers 1 through to 10 but not number 4. We are telling the loop to stop iterating (ie. executing the code after the word continue which in our case is document.write(i + "<br>");) when test condition of i==4 is met but still continue with the looping on the whole.
|
|