foreach to loop overobject array and return the first 3 code example
Example 1: javascript loop through array of objects
var people=[
{first_name:"john",last_name:"doe"},
{first_name:"mary",last_name:"beth"}
];
for (let i = 0; i < people.length; i++) {
console.log(people[i].first_name);
}
Example 2: javascript loop through array of objects
yourArray.forEach(function (arrayItem) {
var x = arrayItem.prop1 + 2;
console.log(x);
});