English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
JavaScript Statements and Variable Declarations
continuestatement terminates the current loop or the execution of the statement in the current iteration of the loop, and continues the loop on the next iteration.
WithbreakIn contrast to the break statement, continue does not completely terminate the execution of the loop:
InwhileIn the loop, test the condition, and if the condition is true, execute the loop again
InforFirst, calculate the increment expression (for example, i++), then test the condition to determine whether another iteration should be executed
continue statement can include an optionallabel, thelabelAllows the program to jump to the next iteration of a labeled loop statement instead of the current iteration. In this case, the continue statement must be nested within the labeled statement.
continue label;
var text = ""; for (let i = 0; 6; i++) { if (i === 3) { continue; } text += "The number is " + i + "<br>"; }Test and see‹/›
All browsers fully support the continue statement:
Statement | |||||
continue | Is | Is | Is | Is | Is |
Parameter | Description |
---|---|
label | (Optional) Identifier associated with statement label |
JavaScript Version: | ECMAScript 1 |
---|
The following example shows a while loop that has a continue statement, which is executed when the value of i is3Executes when:
var text = ""; var i = 0; while (i < 6) { i++; if (i === 3) { continue; } text += "The number is " + i + "<br>"; }Test and see‹/›
JavaScript Tutorial:JavaScript break and continue
JavaScript Tutorial:JavaScript For Loop
JavaScript Tutorial:JavaScript While Loop
JavaScript Tutorial:JavaScript switch
JavaScript Reference:JavaScript Break Statement
JavaScript Reference:JavaScript for Statement
JavaScript Reference:JavaScript while Statement
JavaScript Reference:JavaScript switch Statement