The break statement terminates the current loop and transfers the control out of the loop.
The break statement can also be used to jump out of a loop.
The break statement breaks the loop and continues executing the code after the loop. The break statement, without a label reference, can only be used to jump out of a loop or a switch.
The break statement exits a switch statement or a loop (for, for … in, while, do … while).
When the break statement is used with a switch statement, it breaks out of the switch block. This will stop the execution of more execution of code and/or case testing inside the block.
The following example illustrates the use of a break statement with a while loop. Notice how the loop breaks out early once x reaches 5 and reaches to document.write (..) statement just below to the closing curly brace.