JavaScript continue Statement

Subject: JavaScript

The continue statement in JavaScript is used within loops to skip the rest of the code in the current iteration and immediately proceed to the next iteration.


Syntax

It is typically used inside loop constructs like for, while, or do...while.


Example 1: Using continue in a for Loop


Example 2: continue in a while Loop


Example 3: Skipping Even Numbers


Labeled continue in Nested Loops

You can use continue with a label to skip to the next iteration of an outer loop.


Key Takeaways

  • continue skips only the current iteration of a loop.
  • Works with for, while, and do...while loops.
  • Useful for ignoring specific conditions inside a loop.
  • Labeled continue helps manage nested loop control.
  • Use with care—overusing can reduce code readability.
Next : JS Return