Consider this simple example:
var aa = []; aa[3] = 'three'; alert( aa.length // 4 + '\n' + aa[2] // undefined + '\n' + aa.hasOwnProperty('2') // false );
The number 3 is used to name the property, but it is converted to a string and used as the standard property name (ie, string "3").
Adding a property with the name "3" created one property and set the length to 4, since the length is always set to one more than the largest property value of a non-negative integer value.
No other property is created, the array is "sparse", that is, it does not have sequentially named (numbered) members. The for..in loop can also be used to see that there is only one property.
source share