JavaScript objects have no order stored for properties (according to the spec). Firefox seems preserve the order of definition of properties when using a for...in loop. Is this behaviour something that I can rely on? If not is there a piece of JavaScript code somewhere that implements an ordered hash type?
views:
136answers:
1
+3
A:
No, since the Object type is specified to be an unordered collection of properties, you can not rely on that. (Or: You can only rely on that an object is an unordered collection of properties.)
If you want to have an ordered hash set, you will need to implement it on your own.
Gumbo
2010-05-09 19:39:50
What’s the reason for the down vote?
Gumbo
2010-05-09 19:51:14
Don't drive-by downvotes suck?
Pointy
2010-05-09 20:14:00