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) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36
Browser:
Chrome 118
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
splice
14401774.0 Ops/sec
Object.assign
532073.9 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});