The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
Put continue; inside a loop after the condition for an item you want to skip. It skips the rest of the current loop-body pass and proceeds to the next iteration. In a traditional for loop, the update expression still runs before the loop checks its condition again.
Skip an iteration with a condition
Use an if guard to make the skip condition clear, and place continue; directly inside the loop body:
const values: number[] = [1, 2, 3, 4, 5];
for (let i = 0; i < values.length; i++) {
if (values[i] % 2 === 0) {
continue; // skip even values
}
console.log(values[i]); // 1, 3, 5
}
When the value is even, the loop skips the remaining body statements, including console.log. The loop then advances to its next iteration step.
What happens in each loop form?
The exact next step depends on the kind of loop. JavaScript defines this behavior, and TypeScript uses the same control-flow statement; TypeScript adds a type system rather than a separate version of continue. See the JavaScript continue reference.
#1 Best Overall
for: The loop’s update expression runs, then its condition is checked again. Acontinuetherefore does not skipi++.while: Control returns to the condition. If the skip path fails to change state used by that condition, the loop may repeat indefinitely.do...while: Control proceeds to the condition check after the body.for...of: The loop proceeds to the next value produced by the iterable.for...in: The loop proceeds to the next property key.
Choose `for…of` for values and `for…in` for keys
For arrays and other iterable collections, for...of yields values. for...in enumerates property keys; with an array, those are generally index-like keys rather than the elements themselves. Choose the loop form based on what you need to test or process. The TypeScript Handbook explains the distinction: for...of uses an iterable’s Symbol.iterator, while for...in visits object properties.
Continue an outer loop from a nested loop
An unlabelled continue; affects the innermost enclosing loop. To skip the rest of an outer loop’s current pass from inside a nested loop, give the outer loop a label and target it explicitly:
Rank #2
- TypeScript implements a superset of syntax for strictly typed development, facilitating deep static analysis and enhanced development environment integration. The compiler translates source into standard script formats, ensuring parity across any runtime.
- TypeScript is ideal for front-end developers, full-stack engineers, and software architects who build large-scale web applications. It serves those looking to improve code excellence, reduce bugs through static checking, and maintain complex projects more.
- Lightweight, Classic fit, Double-needle sleeve and bottom hem
outer: for (const row of rows) {
for (const cell of row) {
if (cell === null) {
continue outer;
}
process(cell);
}
}
If a cell is null, this skips the remaining work on that row and starts the next outer iteration. Without outer, continue; would move to the next cell in the inner loop. Labels are useful for this specific control flow, but restructuring the condition or extracting a helper can make deeply nested logic easier to follow.
Quick Recap
Best Value
Avoid common control-flow mistakes
- Do not confuse
continuewithbreak.continueskips the remainder of one iteration;breakexits the loop. - Do not expect
continueto skip aforupdate. The update expression runs before the next condition check. - Keep
continueinside a loop. It must target a loop. Aswitchalone is not a loop, although acontinuein aswitchnested within a loop targets that enclosing loop. - Check the skip path in a
whileloop. If the condition relies on mutable state, ensure that state still changes before the next condition check. - Use the right iteration form. Use
for...ofwhen you need values from an iterable; usefor...inwhen you need property keys.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

