Object.assign vs spread operator

Benchmark created on


Setup

const foo = {}
for (let i = 0; i < 10; i++) {
	foo[`k${i}`] = `v${i}`;
}

Test runner

Ready to run.

Testing in
TestOps/sec
Object.assign
const bar = Object.assign({}, foo)
ready
spread operator
const bar = { ...foo }
ready

Revisions

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