Accessing (n)th key from an object

somonek somonek at gmail.com
Tue Apr 24 13:54:07 UTC 2018


Hi all,

Assuming that

const myObject = {
  one: 123,
  two: 456,
};

could
myObject[in 0] === 'one' // true

be a better alternative of
Object.keys(myObject)[0]

and
myObject[in 3] === undefined

without the need to convert all the object keys into an array, but directly
accessing one.

Best,
Serghei
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20180424/1683de29/attachment.html>


More information about the es-discuss mailing list