Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Slice vs Map (2222211111)
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/147.0.0.0 Safari/537.36 Edg/147.0.0.0
Browser:
Chrome 147
Operating system:
Windows
Device Platform:
Desktop
Date tested:
22 days ago
Test name
Executions per second
slice
134014.6 Ops/sec
map
131316.8 Ops/sec
Tests:
slice
var item = 10; var index = 50; var array = Array.from({length: 100}); var array2 = [...array.slice(0, index), item, ...array.slice(index + 1)];
map
var item = 10; var index = 50; var array = Array.from({length: 100}).map((val, i) => i === index ? item : val);