0
Q:

loop over an array

const myArray = ['foo', 'bar'];

myArray.forEach(x => console.log(x));

//or

for(let i = 0; i < myArray.length; i++) {
  console.log(myArray[i]);
}
5
int[] numbers = {1,2,3,4,5};
for (int i = 0; i < numbers.length; i++) {
	System.out.println(i);
}
1
let fruits = ['Apple', 'Banana'];

fruits.forEach(function(item, index, array) {
  console.log(item, index);
});
// Apple 0
// Banana 1
0
foreach ($objects as $obj) {
   echo $obj->property;
}
1

New to Communities?

Join the community