Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Comparing array.concat.apply short form with empty array vs array.flat vs array.reduce
(version: 0)
Comparing performance of:
array.apply vs array.flat() vs array.reduce
Created:
3 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var array1 = Array(400).fill().map(() => Math.round(Math.random() * 40)); var array2 = Array(400).fill().map(() => Math.round(Math.random() * 40)); var array3 = Array(400).fill().map(() => Math.round(Math.random() * 40)); var array4 = Array(400).fill().map(() => Math.round(Math.random() * 40)); var array5 = Array(400).fill().map(() => Math.round(Math.random() * 40)); var allArrays = [array1, array2, array3, array4, array5];
Tests:
array.apply
var others = [].concat.apply([], allArrays);
array.flat()
var others = allArrays.flat()
array.reduce
var others = allArrays.reduce(((combinedLength, label) => combinedLength + label.length), 0)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
array.apply
array.flat()
array.reduce
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Related benchmarks:
Array.prototype.concat vs spread operator
Array.concat vs Array.prototype.concat.apply
Map vs preallocation vs slice vs spread
concat.apply short form new array vs flat
Comments
Confirm delete:
Do you really want to delete benchmark?