Labeled statements basics
a label is a (non-reserved) word followed by a colon
WHEN prefixing a block with a label THEN break label stops execution of this block
GIVEN a nested loop WHEN breaking the most inner loop THEN both loops stop
GIVEN a nested loop WHEN calling continue label inside THEN the inner loop is skipped
some fun
an unused label: is fine, valid but useless JS
a URL is valid code 😮
Links
Very well readable, easy to understand description of how labels works.
The version of the specification where labels were introduced, see section 12.12. (PDF 723kB)
Labeled statements - the forgotten JS feature – Filip
Required Knowledge
- `let` declaration (Block scope)
Related Katas
label
- label basics
Difficulty Level
INTERMEDIATE
First Published
26 November 2025
Stats
6 tests to solve