Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Splice vs Spread vs Unshift to insert at beginning of array (fixed from slice)
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36
Browser:
Chrome 124
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Splice
3955.0 Ops/sec
Spread
10.6 Ops/sec
Unshift
2680.3 Ops/sec
Script Preparation code:
var array = Array.from({ length: 100 }).map((val, i) => i);
Tests:
Splice
var newArray = array.splice(0, 0, 99);
Spread
var newArray = [99, ...array];
Unshift
var newArray = array.unshift(99);