Chapter V · Control Flow
The continue Statement
continue skips just the rest of the current iteration and moves straight to the next one — the loop keeps going, unlike break which ends it.
01 What Is the continue Statement?
continue stops the current pass through a loop's body early — any code after it in that iteration doesn't run — but, unlike break, the loop itself keeps going: control moves to the update step (in a for loop) or the condition check (in a while loop), and the next iteration begins normally.
02 Simple Example
Skipping one specific value while still logging the rest.
for (let i = 0; i < 4; i++) {\n if (i === 2) continue;\n console.log(i);\n}\n// logs 0, 1, 3
When i is 2, continue skips the console.log for that iteration only — the loop still runs its increment and condition check afterward, and i === 3 executes normally.
03 How It Works
continue jumps to the end of the current iteration's body — not out of the loop entirely. In a for loop, that means the update expression (like i++) still runs before the condition is re-checked; skipping the body doesn't skip the loop's own bookkeeping.
04 Practical Example — Filtering While Iterating
Logging only even numbers by skipping the odd ones.
for (let i = 1; i <= 5; i++) {\n if (i % 2 !== 0) continue;\n console.log(i);\n}\n// logs 2, 4
05 Common Mistakes & Edge Cases
Confusing continue with break is the most common mix-up — continue keeps the loop alive and moves to the next pass; break kills the loop outright. Reach for continue when certain iterations should simply be ignored, and for break when there's nothing left worth doing.
Like break, continue can target an outer loop with a label: continue outer; skips to the next iteration of the labeled loop, not the innermost one.
06 Mental Model
"Skipping a song on a playlist — you jump to the next track instead of stopping the music."
07 Interview Questions
Q: In a for loop, does continue skip the increment step too?
No — continue only skips the remaining body statements; the update expression (e.g. i++) still runs afterward, which is why the loop doesn't stall on the same index forever.
Key Takeaway
continue skips only the remainder of the current iteration and lets the loop carry on — use it to bypass specific cases without abandoning the loop the way break would.