- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is while loop statement in JavaScript?
The most basic loop in JavaScript is the while loop. The purpose of a while loop is to execute a statement or code block repeatedly as long as an expression is true. Once the expression becomes false, the loop terminates.
Syntax
The syntax of while loop in JavaScript is as follows −
while (expression){ Statement(s) to be executed if expression is true }
Example
You can try to run the following example to implement while loop
<html> <body> <script> var count = 0; document.write("Starting Loop "); while(count < 10){ document.write("Current Count : " + count + "<br/>"); count++; } document.write("Loop stopped!"); </script> </body> </html>
- Related Articles
- What is do...while loop statement in JavaScript?
- What is for loop statement in JavaScript?
- What is for...in loop statement in JavaScript?
- The while loop in Javascript
- The do…while loop in Javascript
- How to implement WHILE LOOP with IF STATEMENT MySQL?
- How MySQL WHILE loop statement can be used in stored procedure?
- What are the differences between while loop and do-while loop in Java?
- How to use PowerShell Break statement with the While Loop?
- How do we use continue statement in a while loop in C#?
- How do we use a break statement in while loop in C#?
- How to use nested while loop in JavaScript?
- do…while loop vs. while loop in C/C++
- Java while loop
- What is if statement in JavaScript?

Advertisements