continue

The continue statement is used to stop execution of the script and exit to the top of the loop for another pass through the loop. When the continue statement is used in a for loop, the jump is to the expression in parentheses following the 'for' keyword. When using it within a while loop, the jump is to the expression in parentheses following the 'while' keyword. With the do / while loop, execution jumps to the expression in parentheses following the 'while' keyword. Within a for / in loop, the execution jumps to the next property name for the object being acted upon. Labels may be used with the continue statement to jump to a specific point in a loop. As with all labels the label, when stated, must be followed by a colon. When specifying the label with the continue statement, the statement must be followed by a semi-colon.

syntax:

continue labelName;

EXAMPLE

topOfLoop;

for (expression) {

for (expression) {

if (expression) {

continue topOfLoop;

}

}

}

You see in the example that there is a heirarchy of loops containing two for statements and an if statement. The label 'topOfLoop' is placed at the top. The continue statement with the label is at the end of the tree of loops, indicating that if the expressions within parentheses for the two fors and the if were completed, the entire tree would start executing again from the top, where 'topOfLoop' is located.