Properties
Like strings, arrays have one built-in property: length. This property is equal to the number greater than the last index in the array. This is true even if you skip some indices.
["a", 1, true, null].length;4
var myArray = []; myArray.length;0
myArray[99] = 1;1
myArray.length;100
The new length of myArray is 100 even though it contains only one value at index 99. All the other values are undefined.
The following is the quickest way to add an item to the end of an array, since the length property is one greater than the index of the last item:
myArray = ["a","b","c"]; // Same as myArray[3] = "d" myArray[myArray.length] = "d";