iterating array ES^ js code example
Example 1: javascript loop through array of objects es6
const people = [
{id: 100, name: 'Vikash'},
{id: 101, name: 'Sugam'},
{id: 102, name: 'Ashish'}
];
for (let persone of people) {
console.log(persone.id + ': ' + persone.name);
}
people.forEach(person => {
console.log(persone.id + ': ' + persone.name);
});
people.forEach((person, index) => {
console.log(index + ': ' + persone.name);
});
Example 2: javascript iterate array
String[] myStringArray = {"Hello", "World"};
for (String s : myStringArray)
{
}