DEV Community

Discussion on: Javascript Array.push is 945x faster than Array.concat 🤯🤔

Collapse
 
seanbehan profile image
Sean Behan

0x0.st/zTak.png

I actually got the opposite results. This must only hold true for the V8 engine.

Collapse
 
shiling profile image
Shi Ling

Actually, that's not the same tests, because for the concat test in your screenshot, arr1 is not being assigned the result of arr1.concat(arr2) so it never increases in size. Instead arr3 is being assigned the result. It's not merging 10,000 arrays to a single array, but instead it is just running concat on arrays of the same size 10,000 times.