Accessing (n)th key from an object

T.J. Crowder tj.crowder at
Tue Apr 24 14:18:37 UTC 2018

On Tue, Apr 24, 2018 at 2:54 PM, somonek
<somonek at> wrote:
> ...
> could
> myObject[in 0] === 'one' // true

What's the use case? Relying on the order of the properties in the object
is almost always a bad idea (although if I read the current spec correctly,
`Object.keys` is no longer exempt from order as it once was). The only time
I've seen this done that seemed reasonable was when the object was known to
have a single own enumerable property but that property's name was unknown
(which was, in itself, an X/Y problem -- the real problem was why that name
was unknown/varied at runtime).

-- T.J. Crowder
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list