This example analyzes the use of label statements in JavaScript. Share to everyone for your reference. The specific analysis is as follows:
Recently in looking at W3school, and then see the JS part,
See that list: It's a little weird, and it says,
JavaScript tags
As you can see in the chapter on the switch statement, JavaScript statements are tagged.
To mark a JavaScript statement, precede the statement with a colon:
Grammar:
Break LabelName;
Continue labelname;
Continue statements (with or without a label reference) can only be used in loops.
The break statement (without a label reference) can only be used in loops or switch.
With a label reference, the break statement can be used to jump out of any JAVASCRIPT code block:
In the beginning has not noticed, then Baidu tagged javascript statements, read a blog, is this written, here for reference:
For example:
Parser: While
(token!= null) {
//code omitted here
}
By tagging a statement, you can give the statement a name so that it can be referenced anywhere in the program by using that name, and you can tag any statement,
But the tagged statements are usually those loop statements, that is, while, Do/while, for, and for/in statements, which are usually named loops, you can use the break statement and the continue statement to
Exit a loop or one iteration of the loop.
Such as:
<script type= "Text/javascript" >
outerloop: For
(var i = 0; i < i++)
{
innerloop: for
( var j = 0; J < 10; J + +)
{
if (J > 3)
{break
;
}
if (i = = 2)
{break
innerloop;
}
if (i = = 4)
{break
outerloop;
}
document.write ("i=" + i + "j=" + j + "<br>");
}
</script>
See this example I understand the list: I hope this article will help you with your JavaScript programming.