I don’t remember where, but I once saw it put that for..in loops can go through the elements in any order the implementors like, including forward, backward, randomly, or alternating between forward and back for each execution of a for..in loop. In practice, though, somehow I don’t think that the latter is really the case with any implementation in existence. (Although, there is a certain browser we know who likes to mess things up, so you can never be too sure, but I digress.)
My point is that while there probably isn’t such bad deviation in for..in sequencing in practice, I’d like to know what deviation, if any, there is between ECMAScript implementations. I suppose the main ones now would be JScript, Chakra, Futhark, Carakan, JavascriptCore, SquirrelFish, V8, SpiderMonkey, and TraceMonkey, just for reference.
First of all, here’s a reference from the specification with regard to the order of enumeration:
The only ones I can think of off hand are these:
Earlier (maybe current?) versions of IE would place new properties that were added during enumeration to the end of the enumeration so that they would be visited by the current running
for-inV8 has a different order of enumeration as described in this bug report, which was closed as WorkingAsIntended
Testing in Firefox and V8 show a different order.
This is not much of a list. There certainly may be more. I think it is summed up by @Pointy’s comment. There’s no guarantee. Even if you have an object that reliably enumerates in a consistent manner, this doesn’t mean that it will do so with the next version upgrade. Use tools for how they’re specified to work, not for what merely seems to work.