Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
JS insert at index spread vs Splice
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/130.0.0.0 Safari/537.36
Browser:
Chrome 130
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Array update with spread operator
2640167.2 Ops/sec
Array update with slice and assign
2628476.8 Ops/sec
Script Preparation code:
const ITERATIONS = 500000; var index = ITERATIONS/2; var n = Math.random(); var list = []; for (let i = 0; i < length; i += 1) { list.push(Math.random()); }
Tests:
Array update with spread operator
const clone = [ ...list.slice(0, index), n, ...list.slice(index + 1), ];
Array update with slice and assign
const clone = list.slice(); clone[index] = n;