All the above are correct, in some way. Javascript uses two different ways of accessing properties/method on an object, or items in what is effectively its version of an associative array. As mentioned by Soubok, they are object['propOrMethodName']
and object.propOrMethodName
. They are equivalent.
Even a standard Array, with integer indices, can have named properties/methods. Javascript really makes no distinction on the whole. What you can't do, though, is nonArrayObject[n]
or arrayObject.n
where n is an integer.
In the case of the question, though, collection
is explicitly an object:
var collection = {};
An array, with integer indices, would be declared thus:
var collection = [];
As the latter statement tests collection["null"][n]
(assuming n is again an integer), I'd say that collection is intended to have a series of properties, each of which is an Array. One of those properties is named "null".