Previous
For Loop 
Next
Function 
ABC of JavaScript : An Interactive JavaScript Tutorial
While Loop

While Loop

Syntax :
while(CONDITION) {
BODY
}

This loop will continuously execute the statements in the body as long as a given condition is true. This loop must be handled with care. Always make sure that the given condition will be met - or this loop will continue forever. Let us see an example with the while loop that uses while loop in a situation very similar to the one given in the for loop example.

This basically displays all the elements in an array - the same thing we did using the for loop. Notice how the while loop differs from the for loop. In the while loop, only the condition will be given inside the while loops parenthesis - '(' and ')'.

Previous
For Loop 
Next
Function 

Comments

Anonymous at 26 Mar, 2008 04:28
I need you to help me with the XML while loop syntax, when using stylus studio

Regards,
Mavula Mabena.
Reply to this.
Comment


Comment




Comment Formating : HTML tags a, strong, em, b, i, code, pre, p and br allowed. Other tags will be shown as code(< will become &lt;). Urls, Line breaks will be auto-formated.