The continue statement forces the execution of the code to continue at the beginning of the loop.
When a label is used, JavaScript immediately jumps to the beginning of the loop designated by a label and begins executing code.
Example 1:
<html> <head> <title>A Simple Page</title> <script language="JavaScript"> <!-- var x = 0; while (x < 10) { x++; document.write(x); continue; document.write("You never see this!"); } // --> </script> </head> <body> </body> </html>
Example 2:
<html> <head> <title>A Simple Page</title> <script language="JavaScript"> <!-- var x = 0; while (x < 10) { x++; if (x == 5) { continue; } document.write(x); } // --> </script> </head> <body> </body> </html>
0 comments:
Post a Comment