Arrays contain values, indexed numerically; objects contain properties, indexed by string or symbol.
Arrays are ordered (
arr always comes before
arr); objects are not (you can’t guarantee
obj.a comes before
These differences are pretty esoteric (but important), so let’s think about the property (no pun intended) that makes objects really special. A property consists of a key (a string or symbol) and a value. What makes objects special is that you can access properties by their key.
In general, if you want to list out the contents of the container (called enumeration), you probably want an array, not an object. But objects are containers, and do support property enumeration; you just need to be aware of the special complexities involved.