On Wed, Feb 14, 2018 at 7:03 AM, Raul-Sebastian Mihăilă <
raul.miha...@gmail.com> wrote:
>
> On Wed, Feb 14, 2018 at 8:25 AM, Bob Myers <r...@gol.com> 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?

FWIW: https://jsperf.com/literal-vs-new-array-in-nested-context

`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
test.

-- T.J. Crowder
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to