Front-End developer at cddnation
An array literal can appear anywhere an expression can appear. The first
value will get the property name '0', the second value will get the property name
'1', and so on:
The length property is the largest integer property name in the array plus one. This is
not necessarily the number of properties in the array:
Unfortunately, that leaves a hole in the array. Use slice instead:
The property whose value is 'shi' has its key changed from '4' to '3'. Because every property after the deleted property must be removed and reinserted with a new key, this might not go quickly for large arrays.
The rule is simple:
when the property names are small sequential integers, you should use an array. Otherwise, use an object.
For example, suppose we want to add an array method that will allow us to do computation on an array:
By adding a function to Array.prototype, every array inherits the method.
Useful If contstructors take lots of parameters
By Bård Hovde