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!
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
Scott Wells8,715 Points
Best practices for objects and arrays...
Steven Parker225,769 Points
Arrays actually are objects with a few unique qualities: all the keys are sequentially-assigned integers, they have a "length" property, plus a number of useful methods. For more details see this MDN page on Array.
Arrays are a good choice where you want to store a list of similar items, which may themselves be complex objects. Objects are good for collections of data that are not similar except by association.
For example, imagine you wanted to create a page that showed all the different types of car models. You can use an array to do this, but it would be very complicated and not so efficient. Using an object literal means you can describe exactly what you want about the car, such as the: model; color; make; engine and so on.
1) Arrays can be used for grouping together related content such as a shopping list 2) Objects are also used for grouping together related things, however, it is often used for more complex data where you want to create multiple 'instances' or multiple types of data for the same variable with the use of a function