O'Reilly logo

Real World XML by Steven Holzner

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating JavaScript for Loop Statements

Using loops, you can execute code as many times as you want—which is one of the things computers excel at. The most basic loop is the for loop statement, and here's what this statement looks like in general:

for (initialization;
					test;
					increment) {
    code
}

Here's what's happening: You place an expression in the initialization part of the for loop (which often initializes a variable, called a loop index, to 0), Then you insert a test condition in the test part of the loop to be tested each time the code in the loop has been executed. If the test is false, the loop ends (often the test condition checks whether the value in the loop index exceeds a specified maximum value). On the other hand, if the test condition ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required