Favorites

JavaScript Labeled statement Statement

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
Labeled statement
JavaScript Control FlowThis statement is supported by all modern browsers.
Updated 28th November 2026

A labeled statement gives a name to a loop or block, so break or continue can refer to it, for example to exit an outer loop.

Description

A label is an identifier followed by a colon, placed before a statement. break label and continue label can then target that statement, which is mainly useful for exiting or continuing an outer loop from inside a nested one. Labels are rare; moving the loops into a function and using return is often clearer.

Labels can only be referenced by break and continue statements inside the labeled statement. continue can only target a label on a loop, while break can also target a labeled block, which lets you jump out of a block early. Label names follow the same rules as variable names and live in their own namespace, so they don't clash with variables.

Because labeled jumps are uncommon, many developers find them surprising to read. Before reaching for a label, consider whether moving the nested loops into a function and using return, or using an array method such as some() or find(), would express the intent more clearly.

Syntax

label:
  statement

Example

const grid = [[1, 2], [3, 4], [5, 6]];
search: for (const row of grid) {
  for (const cell of row) {
    if (cell === 4) {
      console.log('Found 4');
      break search;
    }
    console.log('checked', cell);
  }
}

Browser Support

The following information will show you the current browser support for the Labeled statement statement. Hover over a browser icon to see the version that first introduced support for this statement.

This statement is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee