Object.entries(), Object.values()

Jason Orendorff jason.orendorff at gmail.com
Fri Mar 21 07:10:00 PDT 2014


Hmm. It definitely affects the behavior when properties are added or
removed during iteration.

Map and Set iterators are "live". But then, Map and Set iteration is
fully specified and deterministic. That's not in the cards for
property enumeration. So "live" iterators over object properties
would, I'm sure, end up being less compatible across implementations
than arrays, in those mutating cases.

Because of that, and because Object.keys already returns an array, I
think Object.values and Object.entries should too.

-j

P.S. Separately, I just noticed that you can say: `new
Map(Object.entries(obj))`.  That Map constructor was designed to
compose; nice to see that it works.


On Fri, Mar 21, 2014 at 8:18 AM, Kevin Smith <zenparsing at gmail.com> wrote:
> Won't this create a subtle false symmetry?  For the collection types,
> "keys", "entries", and "values" return iterators, but in this case
> "Object.keys" would have to return an array.  Does that matter?
>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>


More information about the es-discuss mailing list