News for hackers. Stuff that matters.
Re:V8 has optimized new JavaScript language features (2018) by chmod775 on Sunday November 08, 2020 @04:33AM (#25024406)
I mean yeah... You're telling the engine to do 2 different things there that just may have the same end-result.

The results diverge specifically when your array contains empty items, which will be converted to items containing undefined with the latter expression.

The JS engine would need a specific optimization for cases where:

- The expression is equivalent to arr.slice(0)

- The iterator being de-structured is a vanilla array

- The array doesn't contain any empty items

Of course your code will be faster when all that's required is just a shallow copy.

There are no comments on this comment yet.