Control Loop Iterations in JavaScript
JavaScript·2 min read·Jan 1, 2026
In JavaScript, the break and continue statements allow you to control the execution flow of loops by either terminating them prematurely or skipping their iterations.
The break keyword
The break keyword is used to immediately terminate a running loop, regardless of whether the loop's condition is met or not.
loop { statements break;}Example
Let's consider this script, that outputs the individual characters of a string until it encounters the 's' character:
const word = 'javascript';let index = 0;while (word[index] !== undefined) { if (word[index] === 's') { break; } console.log(word[index]); index++;Unlock the program 🚀
Pay once, own it forever.
€79
30-day money-back guarantee
- 13 modules
- 113 lessons with full-code examples
- 29 projects with commented solutions
- All future lesson and project updates
- Lifetime access
By submitting this form, you agree to the Terms & Conditions and Privacy Policy.