iteration order for Object

Jeff Walden jwalden+es at MIT.EDU
Sat Mar 12 16:03:36 PST 2011


On 03/12/2011 12:02 AM, Brendan Eich wrote:
> Take it from me, JS objects are not hashmaps and any would-be implementor who tries that and tests on real code is quickly disabused of the notion. It's not going to change, for named properties or any kind of property name.

This is true.

It is also the view of people who are significantly closer to implementations than most web developers are.  HashMap is still probably the better abstraction for most people's purposes.  It's not best for all, certainly, as some people people either reverse-engineer the enumeration order or find one of the places that happens to document it.  (MDN documents the behavior as an implementation extension at least one place if memory serves.  The dime-a-dozen DHTML-espousing site from which I originally learned JS didn't document it.)  Yet a substantial number of people never learn of the property ordering behaviors in web browsers.  So while HashMap is far from what web-quality implementations do, it is generally (there are certainly exceptions) not far from how web developers use objects.

Jeff


More information about the es-discuss mailing list