如何在JavaScript中使用带有Continue语句的标签?
标签可用于继续语句以在JavaScript中更精确地控制流程。标签只是标识符,后跟一个冒号(:),该冒号应用于语句或代码块。
示例
您可以尝试运行以下代码,以学习如何使用带有continue语句的标签
<html>
<body>
<script>
document.write("Entering the loop!<br /> ");
outerloop: // This is the label name
for (var i = 0; i < 3; i++) {
document.write("Outerloop: " + i + "<br />");
for (var j = 0; j < 5; j++) {
if (j == 3) {
continue outerloop;
}
document.write("Innerloop: " + j + "<br />");
}
}
document.write("Exiting the loop!<br /> ");
</script>
</body>
</html>热门推荐
10 父亲简短结婚祝福语大全
11 小朋友祝福语简短的话
12 恭喜订婚的祝福语简短
13 春节拜年祝福语儿童简短
14 怎样给人送祝福语简短
15 祝福语勤奋大全简短英语
16 小寒健康祝福语大全简短
17 求助短信生日祝福语简短
18 出院祝福语简短8字