Home > Web Front-end > JS Tutorial > body text

javascript break指定标签打破多层循环示例_javascript技巧

WBOY
Release: 2016-05-16 17:03:00
Original
1169 people have browsed it

今天看javascript权威指南的时候发现break的语法有两种(break; 和 break label;)。。。以前都没仔细看,就在前几页。

但是不明白label怎么写,于是上网查了一下,找到了一个例子

复制代码 代码如下:

function foo ()
{
dance:
for(var k = 0; k for(var m = 0; m if(m == 2){
break dance;
}
}
}
}

这样就可以直接break掉整个循环嵌套了!!

(c,java的break都是这样的,读书不认真啊。。。)
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!