iteration order for Object

Allen Wirfs-Brock allen at
Sat Mar 12 10:47:08 PST 2011

On Mar 12, 2011, at 10:41 AM, Brendan Eich wrote:

>> What is the rational or use case behind having index properties at first
>> for objects and then the rest of properties?
> The "rationale" (such as it is) is that JS conflates lists and dicts in objects, but users mostly think about one or the other. When combining indexed and named properties, many users still want for-in to work sensibly and that means the list properties first in index order, the dict properties after in insertion order.

In theory it would be equally reasonable to enumerate the index properties (in order) after all the non-index properties.  In practice, implementations that have gone down this road have placed the index properties first.

More information about the es-discuss mailing list