for loop js example

JavaScript
for (i = 0, len = cars.length, text = ""; i < len; i++) { 
  text += cars[i] + "<br>";

 } 
for (statement 1; statement 2; statement 3) {

      // code block to be executed

 }

 var colors=["red","blue","green"];
for(let color of colors){
  console.log(color)
}let array = ['Item 1', 'Item 2', 'Item 3'];

for (let index = 0; index < array.length; index++) {
  console.log("index", index);
  console.log("array item", array[index]);
} var i = 2;
var len = cars.length;
var text = "";
for (; i < len; i++) { 

    text += cars[i] + "<br>";

 } for (i = 0; i < 5; i++) {

   text += "The number is " + i + "<br>";

}

  
Source

Also in JavaScript: