Accessing (n)th key from an object
Mike Samuel
mikesamuel at gmail.com
Tue Apr 24 14:13:12 UTC 2018
On Tue, Apr 24, 2018 at 9:54 AM, somonek <somonek at gmail.com> wrote:
> 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.
>
Why is this something that warrants extra syntax and not an optimization
better left to sufficiently smart engines?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20180424/29fe24f6/attachment.html>
More information about the es-discuss
mailing list