Share via


while Statement (JScript 5.6) 

Executes a statement until a specified condition is false.


while (expression)

      statements 

Arguments

  • 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.
  • statements
    Optional. One or more statements to be executed if expression is true.

Remarks

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

Example

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);

}

Requirements

Version 1

See Also

Reference

break Statement (JScript 5.6)
continue Statement (JScript 5.6)
do...while Statement (JScript 5.6)
for Statement (JScript 5.6)
for...in Statement (JScript 5.6)