Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →Place continue; inside a loop after the condition that identifies an item 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 continue
Use an if guard to make the skip condition clear, then put continue; inside that branch:
As an Amazon Associate I earn from qualifying purchases.
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 console.log. For odd values, execution reaches it normally. TypeScript adds a type system to JavaScript; continue follows JavaScript’s control-flow behavior, rather than being a TypeScript-only feature (MDN: continue).
What happens in each loop type?
Traditional for
After continue, JavaScript runs the loop’s update expression, such as i++, then checks the loop condition. The counter therefore still advances in the example above.
#1 Best Overall
while and do...while
In a while loop, control returns to the condition. In a do...while loop, it proceeds to the condition check at the end of the body. If a while condition depends on state that the body changes, ensure the skip path still changes that state; otherwise, the condition may remain true indefinitely.
for...of and for...in
With for...of, continue skips processing the current value and proceeds with the next value from the iterable. With for...in, it skips the current property key. For arrays, for...in generally gives index-like keys, not element values. Choose the loop form that matches what you need to process: the TypeScript Handbook explains that for...of visits iterable values, while for...in inspects object properties (TypeScript Handbook: Iterators and Generators).
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
Choose between continue and break
- Use
continueto skip the rest of the current iteration and keep looping. - Use
breakto exit the loop entirely.
A continue must apply to a loop. A switch statement by itself is not a loop, but a continue in a switch nested inside a loop continues that enclosing loop. See MDN’s continue reference for the statement’s control-flow rules.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitchesUse a label to continue an outer loop
An unlabelled continue applies to the innermost enclosing loop. To skip the rest of an outer loop’s current iteration from inside a nested loop, label the outer loop and use that label with continue:
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 inner-loop work and starts the next outer iteration. Without outer, continue; would move to the next cell in the current row. Labels can make control flow harder to follow, so consider whether a clearer condition or a helper function would suit deeply nested logic better.
Quick Recap
Best Value
Common errors to avoid
- Expecting a
forloop to skip its update: The update expression runs aftercontinueand before the next condition check. - Forgetting progress in a
whileloop: Make sure the skip path changes state when that state controls whether the loop continues. - Using
for...into process array values: It enumerates keys; usefor...ofwhen you need values. - Using an unlabelled
continuein nested loops to target the outer loop: It affects only the innermost loop. Use a label when the outer-loop jump is intentional.
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.




