Inspired by Lance Pollard's comment in this question, something really weird happened and I have never seen this before...
var strangeArray = {
0:"a",
1:"b",
2:"c",
length: 0,
splice: Array.prototype.splice
}
Now, when you run it:
> strangeArray;
[] <-- you get an empty array.
> strangeArray.length;
0 <-- Holy $#!T
And now:
> strangeArray[0];
"a"
> strangeArray[1];
"b"
> strangeArray[2];
"c"
What the? "Hidden values in an array"?
First I thought because it is an object, that's why. But object
should show like this:
{}
So why is this happening? Please help, I am totally confused. Thanks.