Skip to main content

JavaScript break Statement (Live Playground)

In this tutorial, we will explore the break statement, and learn how to use it in our code.

break Statement

The break statement is used to exit a loop and stop the further execution of iterations when a certain condition is met.


for (let i = 0; i < 10; i++) {
if (i === 5) {
console.log(`Iteration ${i + 1}`);

In the example above, the loop stops when i reaches 5, and the output displays the iteration number from 1 to 5.

Live Playground, Try it Yourself


Understanding and using the break statement is crucial for controlling loop iterations based on specific conditions.