Use the Label statement to add tags to your code for future use.
Statements with label labels are typically used in conjunction with loop statements such as for statements.
var num = 0;outermost:for (var i = 0; i <; i + +) {for (var j = 0; J < J + +) { if (i = = 5 && j = = 5) {break outermost; }; num++; } } alert (num); 55
(break) In the example above, the outermost tag represents an external for statement.
Cycle ideas:
When i = 0 o'clock, j = 0,1,2,3,4,5,6,7,8,9 A total of 10 times, that is to say:
0 10
1 10
2 10
3 10
4 10
5 5 (if judged, jump out of the outermost tag, that is, jump out of all for loops)
So a total cycle of 10+10+10+10+10+5=55 times;
Each num++, the final num = 55;
var num = 0;outermost:for (var i = 0; i <; i + +) {for (var j = 0; J < J + +) { if (i = = 5 && j = = 5) { continue outermost; }; num++; } } alert (num); 95
(continue) In the above example, the outermost tag represents an external for statement.
Cycle ideas:
When i = 0 o'clock, j = 0,1,2,3,4,5,6,7,8,9 A total of 10 times, that is to say:
0 10
1 10
2 10
3 10
4 10
5 5 (if judged, jump out of the outermost label of this cycle)
6 10
7 10
8 10
9 10
10<10, jump out of the loop;
So a total cycle of 10+10+10+10+10+5+10+10+10+10=95 times;
Each num++, the final num = 95;
Label Statement break continue