Function Keyword Updated 17 Oct 2026
break
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
Normal JavaScript, 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");
}The JavaScript above produces this output:
0
1
2
3
4