Home  >  Article  >  Web Front-end  >  javascript break specifies tag to break multi-layer loop example_javascript skills

javascript break specifies tag to break multi-layer loop example_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:03:001212browse

When I was reading the authoritative guide to JavaScript today, I found that there are two types of break syntax (break; and break label;). . . I never looked carefully before, it was just on the first few pages.

But I didn’t understand how to write label, so I checked online and found an example

Copy code Code As follows:

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

This way you can break the entire loop nest directly! !

(The breaks in c and java are all like this, so you don’t study seriously...)
Statement:
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