Object.assign vs `...`

Benchmark created on


Description

Compare Object.assign with the ... syntax

Setup

const currentObject = {
	propertyOne: "one",
	propertyTwo: "two",
	some: {
		more: {
			nested: {
				values: "yay!"
			}
		}
	},	
	andMore: {
		nested: {
			values: "woohoo!"
		}
	}
};

Test runner

Ready to run.

Testing in
TestOps/sec
Object.assign
const result = Object.assign({}, currentObject, {
	propertyOne: "new value one",
	andMore: {
		nested: {
			values: "new nested value"
		}
	}
});
ready
`...`
const result = {
	...currentObject,
	propertyOne: "new value one",
	andMore: {
		nested: {
			values: "new nested value"
		}
	}
};
ready

Revisions

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