Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

while Statement

Executes a statement until a specified condition is false.

while (expression)
   statement
expression

Required. A Boolean expression checked before each iteration of the loop. If expression is true, the loop is executed. If expression is false, the loop is terminated.

statement

Required. Statement to be executed if expression is true. Can be a compound statement.

The while statement checks expression before a loop is first executed. If expression is false at this time, the loop is never executed.

The following example illustrates the use of the while statement.

function BreakTest(breakpoint){
   var i = 0;
   while (i < 100) {
      if (i == breakpoint)
         break;
      i++;
   }
   return(i);
}
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.