break, continue and label statements
break statement will immediately exit the loop, 2904628156
var n = 0; for (var i=1; i < 10; i++) { if (i % 5 == 0) { break; } a ++; } alert(num); //4
Forced to continue following the loop statement. And although also continue statement exits the loop immediately, but will exit the loop from the top of the cycle
Ministry to continue.
var n = 0; for (var i=1; i < 10; i++) { if (i % 5 == 0) { continue; } a ++; } alert(num); //8
var n = 0; outermost: for (var i=0; i < 10; i++) { for (var j=0; j < 10; j++) { if (i == 5 && j == 5) { break outermost; } a ++; } } alert(num); //55
Adding this tag will result will not only lead to a break statement to exit within the
Ministry for the statement (that is, using a variable j loop), but also withdraw from the outside for the statement (that is, using a loop variable i).
var n = 0; outermost: for (var i=0; i < 10; i++) { for (var j=0; j < 10; j++) { if (i == 5 && j == 5) { continue outermost; } a ++; } } alert(num); //95
continue statement forces continue the cycle - to exit the inner loop, the outer loop.
break statement will immediately exit the loop, 2904628156
var n = 0; for (var i=1; i < 10; i++) { if (i % 5 == 0) { break; } a ++; } alert(num); //4
Forced to continue following the loop statement. And although also continue statement exits the loop immediately, but will exit the loop from the top of the cycle
Ministry to continue.
var n = 0; for (var i=1; i < 10; i++) { if (i % 5 == 0) { continue; } a ++; } alert(num); //8
var n = 0; outermost: for (var i=0; i < 10; i++) { for (var j=0; j < 10; j++) { if (i == 5 && j == 5) { break outermost; } a ++; } } alert(num); //55
Adding this tag will result will not only lead to a break statement to exit within the
Ministry for the statement (that is, using a variable j loop), but also withdraw from the outside for the statement (that is, using a loop variable i).
var n = 0; outermost: for (var i=0; i < 10; i++) { for (var j=0; j < 10; j++) { if (i == 5 && j == 5) { continue outermost; } a ++; } } alert(num); //95
continue statement forces continue the cycle - to exit the inner loop, the outer loop.