If you look at MDN , there are examples
outer_block: { inner_block: { console.log('1'); break outer_block; // breaks out of both inner_block and outer_block console.log(':-('); // skipped } console.log('2'); // skipped }
as you can see, you can break with an identifier that selects a label higher in the chain than just the first immediate parent statement.
The default action without an identifier will be
outer_block: { inner_block: { console.log('1'); break; // breaks out of the inner_block only console.log(':-('); // skipped } console.log('2'); // still executed, does not break }
The gap must be inside the label, you cannot break the labels based on the indentation so that the gap is outside.
source share