I have observed the following:
var o = {}; // empty JS object
var a = []; // empty JS array
o.myproperty = "I am property";
a.push("I am array element");
alert(o['myproperty']); // alerts "I am property"
alert(o.myproperty); // alerts "I am property"
alert(a[0]); // alerts "I am array element"
alert(a['0']); // alerts "I am array element"
/* Of course, accessing an array element using dot notation (e.g. a.0) would cause a
SyntaxError: Unexpected number (in JavaScript variable names cannot begin with numbers.)
*/
Also:
'myproperty' in o // evaluates to true
0 in a // true
'0' in a // true
delete o.myproperty; // true, o is now empty
delete o['myproperty']; // true, o is now empty
delete a[0]; // true, a contains now 1 undefined element
delete a['0']; // true, a contains now 1 undefined element
It seems as if adding an element to an array actually creates a numbered property on the array object, that is afterwards used to access the element by reference. But some things do not work on these array element properties exactly as they do on normal object properties (an example is the above deletion). So...
TL;DR ... Are javascript array elements accessed by reference via unseen numbered array object properties?
EDIT seems so: Why is using "for...in" with array iteration a bad idea?