This article describes the usage of loop control statements in JavaScript, including the use of break statements and continue statements, you can refer to JavaScript to provide full control to process loops and switch statements. There may be a situation where you need to exit a loop but not reach its bottom. Alternatively, when you skip a part of the block and start the next iteration directly.
To handle these situations, JavaScript provides break and continue statements. These statements are used to immediately exit any loop or start the next iteration of the loop.
Break statement:
Break statement. This is a simple introduction using the switch statement. It is used to exit the loop in advance and break the closed curly braces.
Example:
This example shows how to use the break statement with the while loop. Note that the loop breaks the front and bottom of the document. write (...) statement from x to 5 at the beginning, and uses the right braces: