Javascript break specifies the tag to break the multilayer loop example

  • 2020-03-30 01:23:10
  • OfStack

Looking at the javascript authority guide today, I found that there are two types of break syntax (break; And break the label) . I didn't look at it very carefully before. It's on the first few pages.

But I don't know how to write the label, so I looked it up on the Internet and found an example
function foo () 
for(var k = 0; k < 4; k++){ 
for(var m = 0; m < 4; m++){ 
if(m == 2){ 
break dance; 

This will break the whole loop nesting!!

(c, Java break is like this, not serious reading ah...)

Related articles: