Javascript While Loop
While loop executes on the truth expression, the statements inside the loop will keep executing as long as the condition passes inside the while loop is true, once the condition evaluates to false, it skips the loop.
Syntax of while loop
while(condition){
Statements;
}
Example
In the given example, we have assigned a variable with numeric '0' and passed the condition in the while loop. The statement inside the loop executes until the variable a is less than 5.
<script>
var a = 0;
while (a < 5){
document.write("Number : " + a+ "<br/>");
a++;
}
</script>