break Last updated: 30. May 2026
Keyword
Terminates the current for, while, or do-while loop and continues executing the code that follows the loop.
Parameters
This function takes no parameters
Returns
This statement does not return a value.
Example
Code example (JS)
JS is normal JavaScript either running in the browser or on the Docly™ server.for (let i = 0; i < 10; i++) {
if (i === 5) {
break; // Stop the loop when i reaches 5
}
write(i + "\n");
} Output
The JS code above produces the output shown below:0
1
2
3
4