Today when I was studying a system, I found that its code has such a structure (simplified):
var result = false;
point:
{
var obj = { key: 1 };
for (var key in obj) {
// .. .
break point;
}
result = true;
}
alert(result);
At first glance, I thought it was a code error, even in Visual Studio cannot format this code correctly. However, if you look closely, the semantics are still very clear, that is, break from the inside of the for loop to the specified point, and this system should not make such a mistake. Because I had never used it in this way, I conducted some tests, and the test result turned out to be that I was not good at academics. . . This is the existing syntax of JavaScript. Break can have position tags. After checking the relevant documents, we found that continue can also have position tags.
Their syntax is:
break [label];
continue [label];
We know that break in the loop body can only jump out of the current loop, and when With break labeled, you can jump to a certain position at will and easily jump out of multiple loops. In addition, break in switch can also be used in this way.
Reference documentation:
https://developer.mozilla.org/en/JavaScript/Reference/Statements/break http:// www.jb51.net/w3school/js/pro_js_statements_break_continue.htm