Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
set array index: slice vs Object.assign
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:120.0) Gecko/20100101 Firefox/120.0
Browser:
Firefox 120
Operating system:
Windows
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
splice
3538480.2 Ops/sec
Object.assign
777893.1 Ops/sec
Tests:
splice
var index = 2; var array = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; var output = [ ...array.slice(0, index), 10, ...array.slice(index + 1) ];
Object.assign
var array = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; var output = Object.assign([], array, {2: 10});