contents   index   previous   next



do {...} while

 

The do statement is different from the while statement in that the code block is executed at least once, before the test condition is checked.

 

var value = 0;

do 

{

   value++;

   ProcessData(value);

} while( value < 100 );

 

The code used to demonstrate the while statement could also be written as the following fragment.

 

do 

{

   var name = GetNameFromTheList();

   SendEmail(name)

} while (name != TheLastNameOnTheList());

 

Of course, if there are no names on the list, the script will run into problems!

 


for