Do...while statement

Source: Internet
Author: User
Tags expression
Statement

Executes a block of statements for the first time, and then repeats the block of statements repeatedly until the conditional expression is equal to false.

do
statement
while (expression) ;

Parameters

Statement

Options available. The statement to execute when expression is true . Can be a compound statement .

Expression

Options available. An expression that can be cast to Boolean true or false . If expression is true, the loop is executed again. If expression is false, the loop ends.

Description

The expression value is not checked until the first repeated execution of the loop completes, ensuring that the loop is executed at least once. Thereafter, the loop checks the expression after each successful repetition.

Example

The following example illustrates how to use the do...while statement to repeat a drives collection.

function GetDriveList(){   var fso, s, n, e, x;   fso = new ActiveXObject("Scripting.FileSystemObject");   e = new Enumerator(fso.Drives);   s = "";   do{x = e.item();      s = s + x.DriveLetter;      s += " - ";      if (x.DriveType == 3)         n = x.ShareName;      else if (x.IsReady)         n = x.VolumeName;      else         n = "[Drive not ready]";         s += n + "<br>";      e.moveNext();   }   while (!e.atEnd());   return(s);}

Requirements

Version 3

Please see

Break Statement | Continue Statement | For Statement | for...in Statement | While statement | labeled Statement



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.