For loop executes statements for given number of times, until condition become false. It is an Entry control loop.
Syntax
for(initialization; condition; iteration)
{
// Set of statements
}
for loop has three parts:
initialization | Initial or starting value from where loop starts |
condition | number of times loop executes |
iteration | Increment or decrement to continue loop cycle or iteration |
Example
<script>
let i;
for(i = 0; i < 10; i++)
{
document.write(i);
}
</script>
Above example prints numbers from 0 to 9.