June 2014
Intermediate to advanced
696 pages
38h 52m
English
The most basic type of looping in JavaScript is the while loop. A while loop tests an expression and continues to execute the code contained in its {} brackets until the expression evaluates to false.
For example, the following while loop executes until i is equal to 5:
var i = 1;while (i<5){ console.log("Iteration " + i); i++;}
This example sends the following output to the console:
Iteration 1Iteration 2Iteration 3Iteration 4
Read now
Unlock full access