iterating of an array of objects in javascipt code example
Example 1: javascript loop through array of objects
var arr = [{id: 1},{id: 2},{id: 3}];
for (var elm of arr) {
console.log(elm);
}
Example 2: how to get value in array object value using for loop in javascript
const people = [
{name: 'John', age: 23},
{name: 'Andrew', age: 3},
{name: 'Peter', age: 8},
{name: 'Hanna', age: 14},
{name: 'Adam', age: 37}];
const anyAdult = people.some(person => person.age >= 18);
console.log(anyAdult); // true