For loop in javascript is most often used to execute a particular block of code with different value each time. So, to reduce the code length instead of adding number of code lines using different value each time for loop is used to execute the single line multiple times.
Syntax of for loop in javascript
for(var varname=startvalue; varname<=endvalue; varname++)
{
// Code block to be executed here each time;
}
Example of For Loop in JavaScript
for(var i=1;i<=7;i++)
{
document.write('<font size=\"' + i + '\">Hello World</font><br />');
}
Above example shows the use of for loop in JavaScript by executing a single line of code how you can increase the size of font in each loop by incrementing the value of variable i.
Continue to next tutorial: Javascript While Loops to learn the other way of Javascript iterations using while loop.