JavaScript Tutorial/Statement/Do While — различия между версиями

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

Текущая версия на 11:25, 26 мая 2010

do...while

do...while loop always executes the loop once before evaluating the expression for the first time.

This difference is seen in the following format:



   <source lang="javascript">

do

   {
      statement;
   }
   while (expression);</source>
   
  

Do While loop

   <source lang="javascript">

<html> <head> <title>A Simple Page</title> <script language="JavaScript">

</script> </head> <body> </body> </html></source>


Use do-while loop and prompt dialog to read user input

   <source lang="javascript">

<html> <head> <title>A Simple Page</title> <script language="JavaScript">

</script> </head> <body> </body> </html></source>


Use integer variable to control a do-while loop

   <source lang="javascript">

<html> <head> <title>A Simple Page</title> <script language="JavaScript">

</script> </head> <body> </body> </html></source>


Use or (||) in do-while condition

   <source lang="javascript">

<html> <head> <title>A Simple Page</title> <script language="JavaScript">

</script> </head> <body> </body> </html></source>