Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Array Shallow Copy: Array.prototype.slice() vs. Array.prototype.concat() vs. Spread syntax vs. Array.from()
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:
2 years ago
Test name
Executions per second
Array.prototype.slice()
324209.5 Ops/sec
Array.prototype.concat()
164826.3 Ops/sec
Spread syntax
317495.4 Ops/sec
Array.from()
271724.7 Ops/sec
Script Preparation code:
var arr = Array(10_000).fill(undefined).map((_, idx) => idx)
Tests:
Array.prototype.slice()
const newArr = arr.slice(0);
Array.prototype.concat()
const newArr = arr.concat([]);
Spread syntax
const newArr = [...arr];
Array.from()
const newArr = Array.from(arr);