In javascript I define an array like this
var arr = [1,2,3];
also I can do
arr[-1] = 4;
Now if I do
arr = undefined;
I also lose the reference to the value at arr[-1].
SO for me logically it seems like arr[-1] is also a part of arr.
But when I do following (without setting arr to undefined)
arr.length;
It returns 3 not 4;
So my point is if the arrays can be used with negative indexes, these negative indexes should also be a part of their length**. I don't know may be I am wrong or I may be missing some concept about arrays.
See Question&Answers more detail:os