标签continue


ES6 标签使用continue

“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