Languages
[Edit]
EN

JavaScript - forEach over array with objects

3 points
Created by:
trincot
360

In this article, we would like to show you forEach() method used to loop over an array with objects in JavaScript.

The forEach() method calls provided function once for each element of an array. In this case, we have an array of objects.

Runnable example:

// ONLINE-RUNNER:browser;

var users = [
	{name: 'Thomas', age: '21'},
	{name: 'Mark', age: '35'}
];

users.forEach((user) => {
	console.log(user.name, user.age);
});

Output:

Thomas, 21
Mark, 35

Note:
Here you can read more about how to use forEach.

See also

  1. JavaScript - how to use foreach? 
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join