Get to know MDN better
The JavaScript exception "unlabeled break must be inside loop or switch" occurs when a break statement is not inside a loop or a switch statement.
break statements can be used to exit a loop or a switch statement, and using them elsewhere is a syntax error. Alternatively, you can provide a label to the break statement to break out of any statement with that label — however, if the label does not reference a containing statement, another error SyntaxError: label not found will be thrown.
break cannot be used outside switch or loops.
Maybe instead of break, you intend to use return to early-terminate a function.
break cannot be used in callbacks, even if the callback is called from a loop.
Instead, refactor the code so the break is used outside the callback.
There's no way to early-terminate a forEach() loop. You can use some() instead, or convert it to a for...of loop.
This page was last modified on Jul 8, 2025 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.