spread vs Object.assign

Benchmark created on


Setup

const obj = {
	a: 1,
	b: '123456',
	c: [100, 101],
	d: -214,
	e: {aa: 123, bb: 456}
};

Test runner

Ready to run.

Testing in
TestOps/sec
spread
const obj2 = { ...obj };
ready
Object.assign
const obj2 = Object.assign({}, obj);
ready

Revisions

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