Object.assign vs vanilla assignment

Benchmark created on


Setup

const data = [
	{
		key: '1',
		value: 'a'
	},
	{
		key: '2',
		value: 'b'
	},
	{
		key: '3',
		value: 'c'
	},
];

Test runner

Ready to run.

Testing in
TestOps/sec
Object.assign
data.reduce((acc, row) => 
	Object.assign(acc, {[row.key]: row.value}), {});
ready
vanilla assignment
data.reduce((acc, row) => {
	acc[row.key] = row.value;
	return acc;
},
{});
ready

Revisions

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