JavaScript DHTML/Language Basics/continue

Материал из Web эксперт
Перейти к: навигация, поиск

Continue in while loop

   <source lang="html4strict">

<html> <head> <title>A Simple Page</title> <script language="JavaScript"> var x = 0; while (x < 10) {

   x++;
   document.write(x+"
"); continue; alert("You never see this!");

} </script> </head> <body> </body> </html>

 </source>
   
  


Continue with condition

   <source lang="html4strict">

<html> <head> <title>A Simple Page</title> <script language="JavaScript"> var x = 0; while (x < 10) {

   x++;
   if (x == 5)
   {
       continue;
   }
   alert(x);

} </script> </head> <body> </body> </html>

 </source>
   
  


Continue with even numbers

   <source lang="html4strict">

<html> <head> <title>A Simple Page</title> <script language="JavaScript"> var x = 0; while (x < 10) {

   x++;
   if (x % 2 == 0)
   {
       continue;
   }
   alert(x);

} </script> </head> <body> </body> </html>

 </source>
   
  


Continue with odd numbers

   <source lang="html4strict">

<html> <head> <title>A Simple Page</title> <script language="JavaScript"> var x = 0; while (x < 10) {

   x++;
   if (x % 2 != 0)
   {
       continue;
   }
   alert(x);

} </script> </head> <body> </body> </html>

 </source>