There are two kinds of declarations that can be used in loops: Break and continue.
JavaScript Break and Continue declarations
There are two special types of declarations that can be used within the loop: Break and continue.
Break
The break command terminates the loop's operation, and then continues to execute the code after the loop (if there is code after the loop).
Instance:
<ptml> <body> <script type= "Text/javascript" > var i=0 for (i=0;i<=10;i++) {if (i==3) {bre AK} document.write ("The number is" + i) document.write ("")} </script> </body> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
Results:
The number is 0
The number is 1
The number is 2Continue
The continue command terminates the current loop and then continues running from the next value.
Instance:
<ptml> <body> <script type= "Text/javascript" > var i=0 for (i=0;i<=10;i++) {if (i==3) {con Tinue} document.write ("The number is" + i) document.write ("")} </script> </body> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
Results:
The number is 0
The number is 1
The number is 2
The number is 4
The number is 5
The number is 6
The number is 7
The number is 8
The number is 9
The number is 10