Set iterators

Allen Wirfs-Brock allen at
Mon Feb 13 20:59:08 PST 2012

On Feb 13, 2012, at 8:14 PM, Peter Michaux wrote:

> I expected a set would have an undefined iteration order to give
> implementations the opportunity to make optimizations that maintaining
> order would not allow.

I would normally agree with you.  ECMAScript for-in property enumeration order is defined in exactly that manner.  However, the experience with JavaScript in browsers is that there is a significant amount of code that has been developed that depends upon a particular enumeration order that is widely used in browsers.  People write code with dependencies (often unintentional) upon the enumeration order used by their favorite browser.  If their code breaks when it is run on other browsers, they complain.  Over time, this is a force that push browsers with less market share to match the implementation decisions of browser with more market share.  This happened with for-in enumeration and I expect it will happen with Set/Map iteration order if we leave it unspecified.


More information about the es-discuss mailing list