Javascript allows you to extend objects on the fly, and as an Array
is an object you can do so.
What you are doing there is adding a new property to your array called abc
and assigning it the value 456
.
So you could say every object in Javascript can be used as a hashmap somehow.
EDIT
It seems that Chrome filters the non-numeric properties of the Array
object at dumping whilst Node dumps every user-defined property. In my opinion Node's way is better since the alpha-numeric property is available in a for in
statement:
var a = [1];
a['abc'] = 2;
for (var i in a) {
console.log(i);
}
// Prints:
// 0
// abc