DEV Community

Discussion on: Flattening an Array, a Performance Test

Collapse
 
antonfrattaroli profile image
Anton Frattaroli

Because some of the results bothered me, I took a look at the JSPerf. I saw some revisions to it since this article was posted. Erik Hughes found that for loop performance declines for large samples (10,000 arrays of 10 elements)

I modified the forEach a bit, found a solution that is middle-of-the-road performant regardless of array size (may be even better using push.apply over the spread operator):