Mutating vs not-mutating

Benchmark created on


Setup


Test runner

Ready to run.

Testing in
TestOps/sec
Mutate in place
const baseObject = {};
for (let i = 0; i < 10000; i++) {
  baseObject['newKey' + i] = i*2;
}
return baseObject;
ready
Spread Every time
let updated = {};
for (let i = 0; i < 1000; i++) {
  updated = { ...updated, ['newKey' + i]: i*2 };
}
return updated;
ready

Revisions

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