GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||
GeezerVison is showing www.geeksforgeeks.org — JavaScript While Loop - GeeksforGeeks JavaScript While LoopLast Updated : 30 Sep, 2025 The while loop executes a block of code as long as a specified condition is true. In JavaScript, this loop evaluates the condition before each iteration and continues running as long as the condition remains true. Here's an example that prints from 1 to 5.
This flowchart shows the working of the while loop in JavaScript. You can see the control flow in the while loop. ![]() Using While Loop to find Traverse an Array
Output 10 20 30 40 Syntax: while (condition) {
Code block to be executed
}Do-While loop A Do-While loop is another type of loop in JavaScript that is similar to the ![]() Example : Here's an example of a
Output 1 2 3 4 5 Syntax: do {
// code block to be executed
} while (condition);Comparison between the while and do-while loop:The do-while loop executes the content of the loop once before checking the condition of the while loop. While the while loop will check the condition first before executing the content.
Comment Explore | ||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |