Test name | Executions per second |
---|---|
Array.push + Array.reverse | 26669.9 Ops/sec |
Array.unshift | 97.0 Ops/sec |
const array = Array.from({length: 10_000}, () => Math.floor(Math.random() * 10_000_000))
const temp = [];
array.forEach(x => temp.push(x));
return temp.reverse();
const temp = [];
array.forEach(x => temp.unshift(x));
return temp;