
The first semicolon is used in place of initialization part and second is used in place of condition part. In this case, the syntax of JavaScript for loop structure is The use of increment/decrement is also optional.Īll the of the js for loop structure are optional. You can also use multiple increment or decrement statements or compound assignment expressions separated by commas. It is supposed as last statement of the body of loop. This part is executed after execution the body of loop. It is used to increase or decrease the value of a control variable. The js for loop continues to execute a body of loop as long as the test condition is true. If it is omitted then a semicolon( ) is used in its place. The initialization part of js for loop is optional. Typically, it is used to assign value to control variable that control the number of repetitions of the loop.

You can initialize multiple variables separated by commas in this part of js for loop but at the semicolon is used. It is executed only the first time when control enters the loop. Specifies the statement used to assign value to a variable. The general syntax or format of for loop structure is:įor(initialization condition increament/decreament) The format of for loop is different from both the while and do-while loop statement. Therefore, for loop is also referred to as a counter loop. The for loop statement is used to execute the body of loop repeatedly for a fixed number of times. JavaScript for Loop- In this tutorial you will learn about for loop in JavaScript with programming examples and flowchart… JavaScript for loop:
