Today, when studying a system, we found that its code has such a structure (simplified ):
Copy codeThe Code is as follows:
Var result = false;
Point:
{
Var obj = {key: 1 };
For (var key in obj ){
//...
Break point;
}
Result = true;
}
Alert (result );
I thought it was a code error, and even Visual Studio could not properly format the code. However, a closer look at the semantics is clear, that is, from the break inside the for loop to the specified point, and the system should not make such a mistake. Because I have never used it like this, I did some tests. The test results are really academic... This is a javascript syntax. break can contain location tags. You can refer to relevant documents and find that continue can also contain location tags.
Their syntax is:
Break [label];
Continue [label];
We know that in the loop body, the break can only jump out of the current loop. When the break is tagged, it can jump to a certain position and easily jump out of multiple loops, in addition, the break in the switch can also be used in this way.
Reference:
Https://developer.mozilla.org/en/JavaScript/Reference/Statements/break
Http://www.jb51.net/w3school/js/pro_js_statements_break_continue.htm