Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript Objects Loop Through Objects Build an Object Challenge

Question not related to the challenge, but when do we use arrays versus objects?

From the title, I'm trying to figure out use cases for both that distinctively has its pros from one another.

I believe arrays are more used for a list of related items (shopping list, list of ages, list of fruits). However, objects are better for listing different data types pertaining to one subject (person has a name, age, address, height, etc). I hope that makes sense!

1 Answer

I like this quote from this page:

If it’s a single entity with named properties, you want an object. If it’s a group of entities of the same type/shape, or if order matters, you likely want an array.

Let me know if this helps!