'continue'或'break'语句与其标签名称之间不允许换行符。
outerloop: // This is the label name
for (var i = 0; i < 3; i++) {
console.log("Outerloop: " + i);
for (var j = 0; j < 5; j++) {
if (j == 3){
continue outerloop;
}
console.log("Innerloop: " + j );
}
}
成功执行上述代码后,将显示以下输出。
Outerloop: 0
Innerloop: 0
Innerloop: 1
Innerloop: 2
Outerloop: 1
Innerloop: 0
Innerloop: 1
Innerloop: 2
Outerloop: 2
Innerloop: 0
Innerloop: 1
Innerloop: 2