

The final-expression part of the for loop is optional, and can be omitted. Here, typically, the counter variable is updated or incremented/decremented.

This is the part of the for statement that is evaluated at the end of each loop iteration.

You may omit the initialization part altogether as it's optional. The expressions in this part are evaluated once before the loop begins. This part is typically used to initialize variables. For example:įollowing topics describe each part of the loop in detail: The for statement is followed by a single statement, or a block of statements that are to be executed in the body of the loop. The three expressions separated by a semi-colon, enclosed within parentheses are used to create the loop. A JavaScript for loop has the following four parts:įor (initialization condition final-expression)
