Array spread reverse VS toReversed

Benchmark created on


Description

Testing the performance of the newer method toReversed introduced by ES2023 to reverse an array object without mutating the original value.

Setup

const array = new Array(10000).fill(Math.round(Math.random()));

Test runner

Ready to run.

Testing in
TestOps/sec
use reverse with spread
const reversed = [...array].reverse();
ready
use toReversed
const reversed = array.toReversed();
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.