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 (iPhone; CPU iPhone OS 17_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.3 Mobile/15E148 Safari/604.1
Browser:
Mobile Safari 17
Operating system:
iOS 17.3
Device Platform:
Mobile
Date tested:
2 years ago
array.splice()
8.5M/s
array.slice()
7.0M/s
array.shift()
3.7M/s
View exact numbers
Test name
Executions per second
✓
array.splice()
8,460,559 Ops/sec
array.slice()
7,040,782 Ops/sec
array.shift()
3,664,651 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()