Any identifier can use as label name. We can use a label to identify a loop and use the continue statements to continue the execution.
Example
Example Program:- (Editor)

Editor is Loading...
Advertisement
Example
label1:
for (a = 0; a < 3; a++) { //The first for statement is labeled "label1"
loop2:
for (b = 0; b < 3; b++) { //The second for statement is labeled "label2"
if (a === 1 && b === 1) {
continue label1;
}
alert("a = " + a + ", b = " + b);
}
}
for (a = 0; a < 3; a++) { //The first for statement is labeled "label1"
loop2:
for (b = 0; b < 3; b++) { //The second for statement is labeled "label2"
if (a === 1 && b === 1) {
continue label1;
}
alert("a = " + a + ", b = " + b);
}
}
Example Program:- (Editor)
Editor is Loading...
Advertisement
Nhận xét
Đăng nhận xét