JavaScript break Statement
The break statement exits a loop or switch immediately, continuing with the code after it.
Description
The break statement terminates the current loop or switch and transfers control to the statement after it. It's used to stop searching once you've found what you need. With a label, it can exit an outer loop from inside a nested one.
break doesn't work inside a forEach() callback; use a for...of loop, or some() or find(), if you need to stop early.
Inside a switch, break ends the current case; without it, execution falls through into the next one. Inside nested loops, a plain break only exits the innermost loop, which is where labeled statements come in. You can't use break to leave a function or an if block on its own; use return for functions.
Syntax
break;
break label;Example
Browser Support
The following information will show you the current browser support for the break statement. Hover over a browser icon to see the version that first introduced support for this statement.
Desktop





Tablets & Mobile





