我刚刚在JS中学习了循环标签。 它可以正常工作,但会发出警告。
意外':'。 mainLoop:// label
var count = 0;
mainLoop: //label
for (i = 0; i < 5; i++) {
childLoop: //label
for (x = 0; x < 5; x++) {
if (x === 2 && count === 0){
count++;
continue childLoop;//will not print 2 and continue in the same loop
}
else if (x === 2 && count === 1){
count++;
continue mainLoop;//will not print 2 and continue in the parent loop
}
else if (x === 2 && count === 2){
count++;
break childLoop;//will not print 2 and break the same loop
}
else if (x === 2 && count === 3){
count++;
break mainLoop;//will not print 2 and break the parent loop
}
console.log(i + "->" + x)
}
}
如何使JSLint期望':'XD? 谢谢