spreading vs in-place mutation

Benchmark created on


Setup

const data = [...Array(1000).keys()]

Test runner

Ready to run.

Testing in
TestOps/sec
in-place mutation
const m = {}

for (let i = 0, len = data.length; i < len; i++) {
  m[i] = data[i];
}
ready
spreading
const m = data.reduce((acc, datum, i) => ({...acc, [i]: datum}), {})
ready

Revisions

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