CKTIS / JavaScript
break — exit a loop or labelled statement
The break statement exits the nearest enclosing loop or switch. Its labelled form exits a specified enclosing statement, including a labelled block.
Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
Syntax
break;
break label;break is a JavaScript reserved word. The statement break; exits the nearest enclosing loop or switch, rather than just the current iteration. In a switch, it prevents execution from continuing through subsequent cases. In contrast, continue advances to the next loop iteration.
The form break label; exits the enclosing statement marked with label, such as an outer loop or a block label: { ... }. The label must exist and enclose this break statement; this is not an arbitrary jump. A line terminator must not separate break from its label.
Using break; outside a loop or switch is a syntax error. A break cannot cross a function boundary or a class static initialization block boundary, even with a label. An applicable finally block runs before the target is exited; its own abrupt completion can override the break.
Examples
const visited = [];
for (let n = 1; n <= 5; n++) {
if (n === 3) {
break;
}
visited.push(n);
}
console.log(visited.join(", "));Result
1, 2
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.