This code will alert all the properties names in the object a. 0,1,2 and hello.
Object.prototype.hello = {};
var a = [1,2,3];
for ( var number in a ) {
alert( number)
}
My question is, I can access the property hello by this syntax:
a.hello
But why can't I access a.0
which should be equal to 1. Isn't the array decleration creating "real properties"?
I know that I can access the properties by a[0] and a["hello"]