break Last updated: 17. Oct 2026
Keyword
Ends the current for, for…of, for…in, while or do…while loop, or a switch statement, and continues with the code after it.
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