continue (Statement)

Force the next iteration of a loop.


ECMAScript edition - 2
JavaScript - 1.0
JScript - 1.0
Internet Explorer - 3.0
Netscape - 2.0
Netscape Enterprise Server - 2.0
Opera - 3.0
JavaScript syntax:-continue aLabelName;
Argument list:aLabelNameThe name of a label associated with some code

The continue keyword is a jump statement. It is used in an iterator loop to proceed to the next cycle without executing the remaining lines in the statement block.

A continue statement can only legally exist inside a while or for loop in an ECMA-compliant implementation. Implementations that provide additional iterator types may also honor the same behavior for the continue statement.

The continue statement would normally be executed conditionally, otherwise it would cause the remaining lines to be redundant since no execution flow would ever reach them. Compilers generally warn you about this, but JavaScript would likely simply ignore it.

The continue statement is obeyed by the smallest enclosing iterator loop.

At version 1.2 of JavaScript, the continue statement was enhanced to support a label as a continuing destination. When the continue is processed, it will jump to the start of the statement that has been labeled. If an iterator is labeled, then the continue is associated with that iterator. This mechanism can only be used in a while, for or for ... in loop.

A labeled continue behaves differently according to the iterator it has been used in.


See also:break, Completion type, do ... while( ... ), for( ... ) ..., for( ... in ... ) ..., Iteration statement, Jump statement, Label, return, Scope chain, Statement, while( ... ) ...


ECMA 262 edition 2 - section - 10.1.4

ECMA 262 edition 2 - section - 12.7

ECMA 262 edition 3 - section - 10.1.4

ECMA 262 edition 3 - section - 12.7

Wrox Instant JavaScript - page - 25