Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
JavaScript Array Shallow Copy: Array.from vs Spread Syntax vs Array.prototype.slice vs Array.prototype.concat
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/149.0.0.0 Safari/537.36
Browser:
Chrome 149
Operating system:
Windows
Device Platform:
Desktop
Date tested:
22 days ago
Array.from
2.4M/s
Array.prototype.concat
2.4M/s
Array.prototype.slice
2.4M/s
Spread Syntax
2.4M/s
For Loop Assign
564K/s
For Loop Push
215K/s
View exact numbers
Test name
Executions per second
✓
Array.from
2,414,838 Ops/sec
Array.prototype.concat
2,408,366 Ops/sec
Array.prototype.slice
2,400,170 Ops/sec
Spread Syntax
2,394,814 Ops/sec
For Loop Assign
564,007 Ops/sec
For Loop Push
214,998 Ops/sec
Script Preparation code:
const array = []; for (let i = 0; i < 1024; i++) array.push(i);
Tests:
Array.from
const a = Array.from(array);
Spread Syntax
const a = [...array];
Array.prototype.slice
const a = array.slice();
Array.prototype.concat
const a = array.concat();
For Loop Push
const a = []; for (const i of array) a.push[i];
For Loop Assign
const a = new Array(array.length); for (let i = 0; i < a.length; i++) a[i] = array[i];