spread vs assign

Benchmark created on


Setup

const arrayOfObjects = Array.from({length: 100}).map(() => ({a:1,b:2,c:3}));

Test runner

Ready to run.

Testing in
TestOps/sec
spread
arrayOfObjects.reduce((acc, item) => ({ ...acc, ...item }), {})
ready
assign
arrayOfObjects.reduce((acc, item) => Object.assign(acc, item), {})
ready

Revisions

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