a statement that does something repeatedly.
JS ⟩ statement ⟩ loop
(statement) does something repeatedly.
continue : skips to the next iteration of the current/labeled loop.
break:breaks the current loop / switch or labeled statement entirely❗
👉 continue vs. break
(nested loop)
labeled statement is needed
when you want to skip to the next iteration of an outer loop that is not the nearest enclosing loop.
when you want to break out of a statement that is not the nearest enclosing loop / switch.
break/continue won't operate across an IIFE function boundary to control an outer loop/block.
📗 You Don't Know JS Yet: Scopes & Closrues
loops
while / do...while
for loops: for / for-of / for-in / for-await
iteration
Loops and iteration
Last updated 2 years ago