Javascript provides a shortcut way of putting all those three things in one place.
var thing= 0;
while (thing < 10)
// do something interesting
thing= thing + 1;
}
|
for (var thing= 0; thing < 10; thing= thing + 1) {
// do something interesting
}
|
These two code-fragments do exactly the same thing. The one on the right is simply more concise, and concentrates the three important aspects of loop control in one place.
|