loading...

re: Javascript Array.push is 945x faster than Array.concat 🤯🤔 VIEW POST

FULL DISCUSSION
 

Your benchmark for 50k length arrays is busted. You are building up arr1 in each run of the test case, which means it is longer and longer on each pass. This is obviously going to favor push, which is only going to copy each power of two, whereas concat has to copy every time.

If you fix the benchmark, concat is faster: jsperf.com/javascript-array-concat...

code of conduct - report abuse