Break statement
The break statement is used to jump out of a loop. It can be used to “jump out” of a switch() statement. It breaks the loop and continues executing the code after the loop.
Example:
Javascript
let content = "" ; let i; for (i = 1; i < 1000; i++) { if (i === 6) { break ; } content += "Geeks" + i + "\n" } console.log(content); |
Output
Geeks1 Geeks2 Geeks3 Geeks4 Geeks5
Contact Us