continue in javascript

continue statement in javascript

continue statement is used to terminate the current loops execution and continues with the next loop.

When used in while loop, the control moves to the condition (eg: while(i<5)).

In for loop, the control moves to the increment/decrement expression (eg: i++).

Example

Try Yourself

Example Explanation

  • In the above loop if the continue statement is not used it will display 0, 1, 2, 3.
  • In the second loop, continue statement is executed. So the following loop will be terminated and the control will move to i++.
  • So except 1 every other values will be displayed.