iterate over array in js code example

Example 1: iterate through array javascript

const array = ["one", "two", "three"]
array.forEach(function (item, index) {
  console.log(item, index);
});

Example 2: iterate array javascript

array = [ 1, 2, 3, 4, 5, 6 ]; 
for (index = 0; index < array.length; index++) { 
    console.log(array[index]); 
}

Example 3: how to loop through array of numbers in javascript

let numbers = [1,2,3,4,5];
let numbersLength = numbers.length;
for ( let i = 0; i < numbersLength; i++) {
    console.log (numbers[i]);
}