Accessing (n)th key from an object

somonek somonek at
Tue Apr 24 18:29:30 UTC 2018

Thanks, hat's probably what I'll do.

I was also thinking looking at @Augusto's approach that if you replace the
object with a Map you can iterate as Augusto mentioned
const [firstProp, secondProp, ...othersKeys] = myMap;
and the order of items should not be a worry.

Any comments on Map's performance in such a case?

On Tue, Apr 24, 2018 at 8:22 PM, T.J. Crowder <
tj.crowder at> wrote:

> On Tue, Apr 24, 2018 at 7:07 PM, Jordan Harband <ljharb at> wrote:
> > Regardless of what's in the spec, relying on objects having an order
> among
> > their properties violates the conceptual mental model of objects: a bag
> of
> > unordered key/value pairs.
> >
> > If you want to convert an array - the best way to preserve order - into
> an
> > object for "performance" reasons, then you may also want to preserve an
> > array of IDs so that ordering can be relied upon.
> Absolutely agree. As I said originally, relying on the order of the
> properties in the object is almost always a bad idea.
> @somonek, an object with an array of keys is probably your best
> solution. Wrap it up in an object with an API that all of the code
> updating it can use, so you don't have consistency issues. You could
> even give it an iterator. :-)
> -- T.J. Crowder
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list