JavaScript continue method to terminate the current loop

Source: Internet
Author: User

Web effects continue methods to terminate the current loop

The continue command terminates the current loop and then continues running from the next value.
Instance:

<script language= ' JavaScript ' >
<!--
Outerloop:
for (var i1 = 1; i1 <= 2; i1++)
{
document.write ("Top of outerloop.<br>");
Innerloop:
for (var i2 = 1; i2 <= 2; i2++) {
document.write ("Top of innerloop.<br>");
document.write ("i1=", I1, "<BR>");
document.write ("i2=", I2, "<BR>");
if (I2 = 2)
{
document.write ("Continue at top of innerloop.<br>");
Continue
}
if (I1 = 2)
{
document.write ("Continue at top of outerloop.<br>");
Continue Outerloop;
}
document.write ("Bottom of Innerloop.<br>");
}
document.write ("Bottom of Outerloop.<br>");
}
document.write ("All done!");
-->
</SCRIPT>

Jump out of the loop

<title>a Simple page</title>
<script language= "JavaScript" >
<!--
var x = 0;
while (x < 10)
{
x + +;
document.write (x);
Continue
document.write ("You never to this!");
}
-->
</script>
<body>

</body>

Example Two

<script language= "JavaScript"
<!--
var x = 0;
while (X < ten)
{
&NBSP;&N bsp;  x + +;
    if (x 2 = 0)
    {
        continue;
   }
    document.write (x);
}
// 
</script>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.