Suggestion: Destructuring object initializer.

T.J. Crowder tj.crowder at
Wed Feb 14 09:24:58 UTC 2018

On Wed, Feb 14, 2018 at 7:03 AM, Raul-Sebastian Mihăilă <
raul.mihaila at> wrote:
> On Wed, Feb 14, 2018 at 8:25 AM, Bob Myers <rtm at> wrote:
>> For example, I did a quick test comparing `[1, 2]` and
>>`new Array(1, 2)` and found that performance was identical, in
>> spite of the claimed inefficiency supposedly introduced by the
>> need to look up `Array`.
> I'm curious how you did that testing. Could you post is here?


`new Array(x, y)` does seem to be nicely optimized. Interestingly, the
one-argument version (passing a non-number as the first argument to avoid
that weirdness in `new Array`) is hugely slower on Firefox. But presumably
that's because of the branch it has to take to check the type of the
parameter (which is something it dosen't share with `Object.assign` vs
spread). In the 2+ argument case, they're about the same, at least in that

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

More information about the es-discuss mailing list