array elements looping over and over in javascript code example
Example 1: loop over an array
let fruits = ['Apple', 'Banana'];
fruits.forEach(function(item, index, array) {
console.log(item, index);
});
// Apple 0
// Banana 1
Example 2: javascript best way to loop through array
var len = arr.length;
while (len--) {
// blah blah
}