iteration order for Object

John Lenz concavelenz at gmail.com
Fri Mar 11 08:13:48 PST 2011


This whole discussion makes reminds me how much JavaScript needs proper
collections.  People use "Object" but they don't really want Object (where
prototype properties leak into data, where they String is the only key type,
where the strings "1.0" and "1" can not be represented in the same map, etc)
they want a HashMap, a LinkedHashMap, a Set, etc.

On Fri, Mar 11, 2011 at 7:48 AM, Charles Kendrick <charles at isomorphic.com>wrote:

> On 3/11/2011 7:35 AM, Wes Garland wrote:
>
>> Someone -- Mark Miller? -- suggested an interesting option when this
>> discussion came up last on
>> this list (around Christmas 2010 IIRC).  Basically -- enumerate named
>> props in insertion order,
>> and numeric props in numeric.   This gets pretty close to what most
>> developers seem to expect,
>> while leaving the door wide open for fast implementation of array-like
>> objects.
>>
>
> Just connecting the dots - I addressed this in my first email on the
> subject.  While it superficially sounds like a good compromise, I actually
> think it's the worst possibility: it requires browser vendors to implement
> limited order preservation, preventing deeper optimizations like sorted
> keys.  At the same time, it requires that applications and frameworks deal
> with lack of order for numeric keys, which are very common: in the use case
> of mapping stored to displayed values, stored values are very often numeric.
>
> I also think that it's surprising and counter-intuitive that numeric keys
> are treated differently from non-numeric.  The reality is that an
> implementation detail of Array is bleeding through to Object.
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110311/c081b68d/attachment-0001.html>


More information about the es-discuss mailing list