arrays

Javascript: Understanding Objects vs Arrays and When to Use Them. [Part 2]

In Part 1 of this blog post I omitted one very important detail about the nature of Arrays. You might have heard this already: "Everything is an Object in javascript!". This is technically true. While String, Bool and Number are literals, javascript silently creates a wrapper Object around the primitive at the time of access. There are couple of other special data types that are not Objects (i.e. Undefined and Null), but for the most part you will be dealing with "things" that inherit from the Object prototype.

Javascript: Understanding Objects vs Arrays and When to Use Them. [Part 1]

See Part 2 here

What are Objects and how do they differ from Arrays in Javascript?
When is it advantageous to use one over the other?

I ran into this question several times while browsing through stackoverflow's javascript queue so I decided to recycle my answers, elaborate a bit and make it into a blog post. If you are new to javascript, understanding these two data types is very important and could potentially save you some headache down the road.

Declaration & Augmentation

Ready for transformation?