Easy Tutorial
❮ Prop Audio Src Prop Style Columnrulewidth ❯

JavaScript continue Statement

JavaScript Statements Reference Manual

Example

This example demonstrates the use of the continue statement in a loop.

The loop block skips the current iteration when the value of i is "3":

text The output is:

The number is 0The number is 1The number is 2The number is 4

More examples are included at the bottom of this article.


Definition and Usage

The continue statement is used to skip one iteration in a loop and continue with the next iteration.

The difference between continue and the break statement is that break terminates the entire loop, while continue terminates only the current iteration.

However, the continue statement exhibits different behaviors in two types of loops:

The continue statement can be applied with an optional label reference.

Note: The continue statement (without a label reference) can only be used within loops or a switch statement.


Browser Support

Statement Chrome Edge Firefox Safari Opera
continue Yes Yes Yes Yes Yes

Syntax

With optional label reference:

Technical Details

| JavaScript Version: | 1.0. JavaScript 1.2 supports optional label references. | | --- | --- |


More Examples

Example

This example demonstrates the use of the continue statement in a while loop.

The loop block skips the current iteration when i is "3":

text The output is:

The number is 1The number is 2The number is 4The number is 5

Example

This example demonstrates the use of the continue statement in a for loop.

The loop skips the current iteration when the array element is "Saab":

text The output is:

BMWVolvoFord

Example

Using the continue statement with a label reference to skip out of a block:

text The output is:

i = 0, j = 10 11 13 14i = 1, j = 10 11 13 14i = 2, j = 10 11 13 14

Related Pages

JavaScript Tutorial: JavaScript Break and Continue

JavaScript Tutorial: JavaScript Loops

JavaScript Tutorial: JavaScript While Loop

JavaScript Tutorial: JavaScript break Statement

JavaScript Reference Manual: JavaScript for Statement

JavaScript Reference Manual: JavaScript while Statement


❮ Prop Audio Src Prop Style Columnrulewidth ❯