Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Adding to an array with push.apply vs spread vs loop
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:126.0) Gecko/20100101 Firefox/126.0
Browser:
Firefox 126
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Adding with Function.prototype.apply on the push method
9535217.0 Ops/sec
Adding with spread
9371289.0 Ops/sec
Adding with loop
8887086.0 Ops/sec
Tests:
Adding with Function.prototype.apply on the push method
var target_array = []; var new_data = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]; target_array.push.apply(target_array, new_data)
Adding with spread
var target_array = []; var new_data = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]; target_array.push(...new_data)
Adding with loop
var target_array = []; var new_data = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]; for(let i = 0; i < new_data.length; i++){target_array.push(new_data[i])}