Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / JavaScript

continue — skipping the rest of a loop iteration

The continue statement skips the remaining part of the current loop iteration and proceeds to the loop's next step. Unlike break, it does not end the loop. An optional label can select an enclosing loop.

Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support

Syntax

continue;
continue label;

continue is a reserved JavaScript keyword. The continue; statement skips the remaining statements in the current iteration of the nearest enclosing loop. Unlike break, it does not terminate the entire loop.

In a classic for loop, the update expression runs next, followed by the condition check. In while and do...while, the next step is checking the condition; in for...in and for...of, it is advancing to the next item. In while, take care not to skip an update needed for the loop to terminate.

The form continue label; targets an enclosing loop marked with label, including from inside a nested loop. The label cannot target an ordinary block. Do not put a line break between continue and its label: automatic semicolon insertion can then end the statement as continue;.

The statement must be inside a loop; it cannot cross a function boundary or a class static initialization block boundary. Consequently, it cannot be used inside a callback to continue an outer loop. An applicable finally block runs before control transfers; its own abrupt completion can override the pending continue.

Examples

const kept = [];
for (let n = 1; n <= 5; n++) {
  if (n % 2 === 0) continue;
  kept.push(n);
}
console.log(kept.join(', '));

Result

1, 3, 5

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources