0
0
Javascriptprogramming~10 mins

Continue statement in Javascript - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Continue statement
Start loop iteration
Check condition
Yes
Check continue condition
Skip rest
Next iteration
No
Exit loop
Each loop iteration checks if it should skip the rest using continue; if yes, it jumps to the next iteration immediately.
Execution Sample
Javascript
for(let i=0; i<5; i++) {
  if(i === 2) continue;
  console.log(i);
}
This code loops from 0 to 4, but skips printing when i is 2.
Execution Table
IterationiCondition i<5Check if i===2ActionOutput
10truefalsePrint 00
21truefalsePrint 11
32truetrueContinue (skip print)
43truefalsePrint 33
54truefalsePrint 44
65false-Exit loop
💡 i reaches 5, condition i<5 is false, loop ends
Variable Tracker
VariableStartAfter 1After 2After 3After 4After 5Final
i0123455
Key Moments - 2 Insights
Why does the loop skip printing when i is 2?
Because at iteration 3 (i=2), the condition i===2 is true, so continue runs and skips the print step as shown in the execution_table row 3.
Does continue stop the whole loop?
No, continue only skips the rest of the current iteration and moves to the next one, as seen in the flow and execution_table rows.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the output at iteration 3?
A2
BNo output
C3
DError
💡 Hint
Check the 'Output' column at iteration 3 in the execution_table.
At which iteration does the loop stop running?
AIteration 4
BIteration 5
CIteration 6
DIteration 3
💡 Hint
Look at the 'Condition i<5' column and the exit_note in the execution_table.
If we remove the continue statement, what will happen at iteration 3?
AIt will print 2
BIt will skip printing
CIt will cause an error
DIt will exit the loop
💡 Hint
Without continue, the print action happens every iteration as shown in the execution_table except when continue is used.
Concept Snapshot
continue statement in loops:
- Skips the rest of current iteration
- Moves immediately to next iteration
- Useful to skip specific cases
Syntax:
for(...) { if(condition) continue; ... }
Full Transcript
This visual trace shows how the continue statement works in a JavaScript for loop. The loop runs from i=0 to i=4. When i equals 2, the continue statement runs, skipping the print step for that iteration. The loop then continues with i=3. The variable i increments each iteration until it reaches 5, where the loop ends because the condition i<5 becomes false. The key point is that continue does not stop the loop, it only skips the rest of the current loop cycle and moves to the next one.