The Javascript for statement is a loop mechanism that will execute code as long as the condition evaluation continues to be true. It stops running when the condition returns false.
You establish three parameters inside of its parenthesis:
- Create the iteration variable(usually named "i")
- Establish the condition to evaluate each pass of the loop
- Iterate(increase) the variable by 1 each pass of the loop
Javascript CODE EXAMPLE
for (var i = 0; i < 5; i++){
document.write("Pass index "+i+" of the loop<br />");
}
Related Material
· Javascript loops
· break
· continue