do....while
construct
JS Home <<
JS Reference <<
do....while
Creates a loop structure.
Description
Creates a loop through a section of code which will be executed at least once.
Syntax
Signature | Description |
---|---|
do | Creates a loop through a section of code which will be executed at least once. |
Parameters
Parameter | Description |
---|---|
statement | Executed first time through the loop and afterwards while expression evaluates to true . |
condition | An expression that evaluates to true or false and is tested after each pass through the loop. |
Examples
The code below shows a do....while
loop.
// this loop will execute once.
var bVariable = 11;
do {
alert('bVariable = ' + bVariable);
bVariable += 4;
} while (bVariable < 10);
alert('left do....while loop');
Related Tutorials
JavaScript Intermediate Tutorials - Lesson 4 - While and Do....While Loops