for Loop in JavaScript

A for loop in JavaScript is the most common type of loop in JavaScript. It is the type of loop that allows you to iterate over a collection of items, such as an array or object.

The syntax of for loop is:

for (initialization, condition, increment/decrement){
    //code
}

where.

Initialization is the first step where you initialize a value for the beginning of the loop. Typically, the start value is 0, but can be changed as per the condition.

Condition is the second step in which when the statement satisfies the condition, the loop ends.

increment/decrement is the final step in which the value gets incremented or decremented by 1 or given value as per the condition.

Let's understand for loop with the help of an example.

500 Internal Server Error

500 Internal Server Error