get for loop result in array javascript code example
Example 1: javascript loop through array
const myArray = ['foo', 'bar'];
myArray.forEach(x => console.log(x));
//or
for(let i = 0; i < myArray.length; i++) {
console.log(myArray[i]);
}
Example 2: how to iterate through an array in javascript
const array = ["one", "two", "three"]
array.forEach(function (item, index) {
console.log(item, index);
});