What is an array in Javascript?

Arrays in Javascript - difference between arrays and objects

CLICK the button below (sneak peek) to peek at the code.

According to the Webster dictionary "to array" is to sort out things in an orderly way. So in computer science it comes to mean (as a noun) an ordered row of data, or as it is also called, a field. So an array is nothing but a set of data that has been sorted. You can go about declaring an array in different ways. First the easy and clear way:

So here you have got an array of 4 (!) elements. One of the mistakes made most often, is to forget that an array starts with "0". I advise you to keep this in mind.

You can also declare it this way, seeing that an array actually starts with zero:

Or the very short form, which makes it very clear to see it as an object:

In some ways this is like an array:

var person = {
  3:"was one of the greatest artists of all time."

But see, whereas an array inherits from object, its prototype is "array", which has got quite a few extras:

an array is an object as can be seen from the prototype

This is the object without the extras, so we can't say that object and array are equivalent and we can see that an array has got properties and methods that it inherits from object, but an object is not an array because it has only got the properties and methods of object:

difference between array and object, an arry is not an object but inherits from object
submit to reddit

Sneak peek of the server side code