Hosting Solutions
mobile_logo Table of Contents
seal_frontseal_back

do while

The do...while statement is an inverted while statement. It will execute code as long as the condition returns a value of true. In contrast to other loops the first iteration of the do...while loop is always guaranteed to run due to the condition evaluation being at the bottom.

Syntaxdo { // execute code } while ( true );
var i = 0; do { document.write("Loop index: "+i+"<br>"); i++; } while ( i < 5 );

JavaScript

Statements

breakconstcontinuedo whileforfor inif elselabelreturnswitchtry catchvarwhilewith