References

Beginner-friendly references for web development, with live, editable examples.

The JavaScript continue statement

Statement JavaScript All modern browsers Updated
Quick answer

The continue statement skips the rest of the current loop iteration and jumps straight to the next one. if (skip) continue; is a clean way to ignore certain items mid-loop. Unlike break, it keeps the loop running — it only skips one pass.

Overview

continue says "skip the rest of this one, move on to the next." When it runs inside a loop, everything below it in the current iteration is skipped, and the loop proceeds to its next pass. It's the tidy way to handle exceptions in a loop — ignore the empty rows, skip the disabled items, pass over anything that doesn't qualify — without wrapping the whole body in an if.

The contrast with break is the key thing to keep straight: break leaves the loop entirely, while continue stays in the loop and just skips the current iteration. One stops; the other steps over.

Used well, an early continue (a "guard") flattens loop bodies and improves readability — if (!item.active) continue; at the top reads cleanly. That said, when you're continuing in order to process only a subset, a filter() (often chained with map()) frequently expresses the intent more declaratively than a loop with continue.

Syntax

for (const item of items) {
  if (!item.active) {
    continue;   // skip inactive items
  }
  process(item);
}

Example

Live example
<pre id="out" style="font:15px ui-monospace,monospace"></pre>
<script>
  const nums = [1, 2, 3, 4, 5, 6];
  const odds = [];

  for (const n of nums) {
    if (n % 2 === 0) continue; // skip evens
    odds.push(n);
  }

  document.getElementById('out').textContent = 'odds: ' + odds.join(', '); // 1, 3, 5
</script>

Best practices

  • Use an early continue as a guard to skip items and flatten the loop body.
  • Remember it skips one iteration; use break to leave the loop entirely.
  • When filtering a subset to process, filter() is often clearer than continue.
  • Like break, continue can target a labeled outer loop when nested.

Frequently asked questions

What does continue do in JavaScript?
It skips the rest of the current loop iteration and moves on to the next one, without leaving the loop.
What is the difference between continue and break?
continue skips just the current iteration; break exits the loop completely.
When should I use continue instead of an if?
An early continue guard (if (skip) continue;) keeps the main loop body un-nested, which is often more readable than wrapping everything in an if.
Can I use continue in a forEach loop?
No. forEach() doesn't support continue — an early return in the callback skips to the next item, or use a for...of loop.