- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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
The while loop in Javascript
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.
Example
For example −
let i = 0; while (i < 5) { console.log("Hello"); i = i + 1; }
Output
This will give the output −
Hello Hello Hello Hello Hello
- Related Articles
- The do…while loop in Javascript
- What is while loop statement in JavaScript?
- do…while loop vs. while loop in C/C++
- What is do...while loop statement in JavaScript?
- How to use nested while loop in JavaScript?
- What are the differences between while loop and do-while loop in Java?
- Java while loop
- Infinite while loop in Java
- Do-while loop in Arduino
- While loop in Lua Programming
- Difference between for loop and while loop in Python
- Difference Between while and do-while Loop
- Find the longest sub array of consecutive numbers with a while loop in JavaScript
- How to show a while loop using a flow chart in JavaScript?
- For Versus While Loop in C

Advertisements