Are node.js arrays actually hashmaps?
arrays, hashmap, javascript, node.js, v8
Solution
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
Problem
To my surprise, this code actually works in node.js: ``` var arr = new Array(); // also works: var arr = []; arr[0] = 123; arr['abc'] = 456; arr; // node.js: [ 123, abc: 456 ], chrome: [123] ``` I've always thought that an array stores its objects in order, only accessible by an integer key, like a std::vector in C++. However, here it's acting like a map or an object. Adding to the confusion, the same code works as expected in chrome, returning an array with a single entry, 123. I thought node.js and chrome javascript use the same internal engine, V8. What's going on here?