M
Michael Winter
OK
JavaScript array is not really an array.
That probably depends on the definition that you want to use. The
definition that I'm accustomed to is a homogeneous collection of
elements located sequentially in memory. However, more generic
definitions are just as acceptable.
What arrays in ECMAScript certainly are, are Object objects with
specialised behaviour. The same can be said for any native object.
arrayObject.length keeps the highest index you managed to use so far.
The highest plus one.
It has *no* connection with the actual array's length, it's just called
so for further convenience.
I disagree. The array:
[, 1]
has two elements, and a length of two. Just because the first element is
undefined doesn't make the size any smaller. If you think it should,
then you are probably using the wrong data type.
[snip]
Could we at least to mention in the FAQ's, that despite array and
associative array (map, collection, hash table) is the same thing in
JavaScript
OK, how many times does this need to be said: an array is not an
associative array, and an object is not an associative array. That might
be how they are implemented, and that's the sort of behaviour they
appear to possess, but that doesn't change the reality of the situation.
if you do arrayObject[SomeNumber] = someValue, it counts it in
arrayObject.length
If SomeNumber is a 32-bit unsigned integer, yes.
It also lets you to use standard array methods on this member. (1st
category)
The Array prototype methods generally operate in the range of named
properties [0, length), so that much is obvious. Some work outside that
range, namely when extending the number of elements.
if you do arrayObject[SomeString] = someValue, the engine doesn't it in
arrayObject.length
If SomeString represents an array index, then that assignment certainly
does affect the length. If SomeString is not an array index, then of
course it won't affect the length.
and you cannot use standard array methods on this member. (2nd
category)
For the previously cited reason.
Until JavaScript/JScript engine producer will rectify this obvious bug,
It is not a bug. It is clearly defined behaviour.
you need to be very attentive while putting new members in your
arrayObject. [...]
One merely needs to understand the language. You clearly don't. I
suggest you get yourself a copy of ECMA-262 and read items 15.4 and
15.4.5.1, and compare the latter to 8.6.2.2.
Mike