The difference between break and continue
1 2 3 4 5 6 |
|
•When i=5 and 10, break will be executed and the loop will exit.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
|
•When i=5 or i=10, the for loop will continue to be executed according to the value of i and exit the loop
When executing multiple loops
The situation of break
1 2 3 4 5 6 7 8 9 10 |
|
This is the break to the outermost loop
1 2 3 4 5 6 7 8 9 10 |
|
This is the time to break into the inner loop. Although it will not jump out for the time being, it will still jump out after executing it 4 times
continue situation
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
Whenever i is greater than or equal to 5, the continue loop will pop up, so there will be forty times less.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
The same principle, the loop will still continue to execute, just 40 times less, because the limit is always the value of i, and it will not be true if i is less than or equal to 5 .
The above is the detailed content of Detailed explanation of the difference between break and continue in javaScript. For more information, please follow other related articles on the PHP Chinese website!