News for hackers. Stuff that matters.
Re:V8 has optimized new JavaScript language features (2018) by bufferoverflow on Saturday November 07, 2020 @07:42PM (#25021525)
I'm pretty sure destructuring is still slow as hell. Like if you want to clone an array, arr.slice(0) is 3x faster than [...arr]
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.