For Loops
Introduction to for loops in JavaScript.
In this lesson, we will see a type of loop that offers a more controlled approach, the for
loops.
for
loops
for
loops let you do a certain number of iterations. The number of iterations is defined within the definition of a for
loop along with the initialization of variables for the loop.
Within a for
loop, you have three statements each separated by a ;
. Each statement is as follows:
initializer
: This is executed only once. This is where variables are usually initialized for the loop and can be optional.