JavaScript Continue
Continue statement is used to skip the execution of further statements inside the immediate loop and continue with the next iterations.
The syntax of continue statement is
continue;
JavaScript continue statement can be used inside the following statements.
- for
- for in
- for of
- while
- do while
Usually, continue statement is used conditionally inside a loop statement.
We will go through examples with break statement for each of these statements.
Continue For Loop
In the following example, we use continue statement to continue with next iterations of For loop, when i == 4
.
index.html
Continue For-in Loop
In the following example, we use continue statement to continue with next properties of the object in For-in loop when value == 22
.
index.html
Continue For-of Loop
In the following example, we use continue statement to continue with next items of the iterable object in For-of loop when the value of item is banana
.
index.html
Continue While Loop
In the following example, we use continue statement to continue with next iterations of While loop when i == 5
.
index.html
Continue Do-While Loop
In the following example, we use continue statement to continue with next iterations of Do-While loop when i == 5
.
index.html
Conclusion
In this JavaScript Tutorial, we learned what continue statement is in JavaScript, its syntax, and usage with examples.