Phrogz said:
And, for what it's worth, JavaScript's Object primitive is also an
associative array that retains insertion order for iterating keys,
while exhibiting performance characteristics of a hash.
Clarification: apparently the ECMAScript spec[1] don't actually require
that the insertion order be preserved; it's just that the major JS
engine implementations happen to do so. On the order of properties, the
spec actually says:
"Step 5: Get name of the next property [...] that doesn't have the
DontEnum attribute.
[...]
The mechanics of enumerating the properties (step 5 in the first
algorithm, step 6 in the second) is implementation dependent. The order
of enumeration is defined by the object. Properties of the object being
enumerated may be deleted during enumeration. If a property that has
not yet been visited during enumeration is deleted, then it will not be
visited. If new properties are added to the object being enumerated
during enumeration, the newly added properties are not guaranteed to be
visited in the active enumeration."
[1]
http://www.ecma-international.org/publications/files/ecma-st/ECMA-262.pdf