step through array in loop javascript code example
Example 1: iterate array javascript
array = [ 1, 2, 3, 4, 5, 6 ];
for (index = 0; index < array.length; index++) {
console.log(array[index]);
}
Example 2: loop through array javascript
/* ES6 */
const cities = ["Chicago", "New York", "Los Angeles"];
cities.map(city => {
console.log(city)
})
Example 3: how to loop through an array
int[] numbers = {1,2,3,4,5};
for (int i = 0; i < numbers.length; i++) {
System.out.println(i);
}