There is no such thing as a “linked array” in JavaScript. [ 1, 2, 3 ] - the syntax of the array literal; it initializes the array. { foo: "bar" } - object literal syntax; it initializes the object. However, the quirk of JavaScript is that arrays are also objects, so this code "works":
var data = []; data["first"] = []; data["first"]["second"] = [];
... but you should not do this, because it makes no sense. You initialize an empty array ( [] ), but then you do not use it as an array, you use it as an object. If you use property names ( data["first"] , which is equivalent to data.first ) instead of integer keys ( data[0] ), then you want to use an object. There is no scenario in which you have to initialize the array when you are going to use it as an object.
Typically, if you want each element to have a name or to quickly access them by name, use Object ( {} ) and use the string for the keys. If you need to be able to iterate over items in order, use an array with integers for the keys.
I don’t know the exact cause of your memory error, especially not seeing your actual code, but you should definitely use Object ( {} ) and not an array ( [] ) when you are not using integer keys. JavaScript engines optimize everything they can, and arrays and objects are no exception, so it is not surprising that when using an array in such a way that the engine does not expect this to cause performance or memory problems.
PS As a style, consider the use of property notation (or "dot notation", ie foo.bar ) instead of musical notation (ie foo["bar"] ) when working with objects:
var data = {}; data.first = {}; data.first.second = {}; data.first.second2 = "hello";
This is exactly equivalent to the code you sent, but it is easier to read and may help you remember that objects and arrays have different uses. You can also simply express this as a literal of a single object:
var data = { first: { second: {}, second2: "hello" } };
It is also exactly equivalent and helps you see the "structure" of your object (as long as you are disciplined with indentation).
Most JavaScript style guides say that you should always use "dot notation" if you don't have keys that could cause a syntax error. For example, if you have a property called "foo/bar" , you obviously cannot do this:
var obj.foo/bar = 1;
... because it is a syntax error. Therefore, you must do this:
var obj["foo/bar"] = 1;
... which is absolutely true. These cases are usually the exception, so I would advise you to always use dot notation if you do not need to use musical notation.