We're looking for a user researcher to understand the needs of developers and designers. Is this you or someone you know? Check out the post: https://mzl.la/2IGzdXS

break Redirect 1


Terminates the current loop, switch, or label statement and transfers program control to the statement following the terminated statement.

Implemented in JavaScript 1.0, NES 2.0
ECMAScript Edition ECMA-262 (for the unlabeled version)
ECMA-262, Edition 3 (for the labeled version)


break [label];


Identifier associated with the label of the statement.  If the statement is not a loop or switch, this is required.


The break statement includes an optional label that allows the program to break out of a labeled statement. The break statement needs to be nested within this labelled statement. The labelled statement can be any block statement; it does not have to be preceded by a loop statement.


The following function has a break statement that terminates the while loop when i is 3, and then returns the value 3 * x.

function testBreak(x) {
   var i = 0;

   while (i < 6) {
      if (i == 3) {
      i += 1;
   return i * x;

See also

Document Tags and Contributors

Last updated by: Sheppy,