Subj : Re: Retaining property order in Rhino To : Larry Blair From : Igor Bukanov Date : Wed Apr 30 2003 02:52 pm Larry Blair wrote: > A major difference between Rhino and Spidermonkey is that if you define > a bunch of properties for an object in SM ('var x={a:"B", c:"D");'), > "for..in" will return the properties in the order defined and Rhino does > not. Unfortunately, a number of the programmers who worked on our > application wrote code that relies on this behavior. Since grep finds > 372 instances of "for..in" in the app, it would be far simpler for me to > change Rhino than to change the app. EcmaScript standard does not require for (...in..) to enumerated properties in any given order and if you relied on that particular SM property, your program by definition is not portable. Rhino holds property internally as a hash table and its getIds implementation simply scan the internal representation and record all found properties to the resulting array. Thus the relation between getIds and define order should be random (or the hash table code is broken). In principle as a workaround it should be possible to create a subclass of ScriptableObject that uses a linear search to look for properties but the longer term solution would be to fix the application. Regards, Igor .