Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Slice vs Splice vs Shift
Compares the speed for removing 2 items from the beginning of an array
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Android 14; Mobile; rv:131.0) Gecko/131.0 Firefox/131.0
Browser:
Firefox Mobile 131
Operating system:
Android
Device Platform:
Mobile
Date tested:
one year ago
array.shift()
62.2M/s
array.slice()
26.4M/s
array.splice()
22.4M/s
View exact numbers
Test name
Executions per second
✓
array.shift()
62,249,896 Ops/sec
array.slice()
26,359,738 Ops/sec
array.splice()
22,396,854 Ops/sec
Script Preparation code:
var array = [1, 2, 3, 4, 5, 6, 7, 8] var itemsToRemove = 2
Tests:
array.slice()
array = array.slice(2)
array.splice()
array.splice(0, itemsToRemove)
array.shift()
for (let i = 0 ; i < itemsToRemove ; i++) array.shift()