Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
My JavaScript spread operator vs Object.assign performance
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.3 Safari/605.1.15
Browser:
Safari 16
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
Using the spread operator with constant inside
20906868.0 Ops/sec
Using Object.assign
11405674.0 Ops/sec
Using the spread operator
10418629.0 Ops/sec
Tests:
Using the spread operator with constant inside
const firstObject = { sampleData: 'Hello world' } const secondObject = { moreData: 'foo bar' } const finalObject = { ...secondObject, __key: "a key", __src: "a src", };
Using Object.assign
const firstObject = { __key: "a key", __src: "a src", } const secondObject = { moreData: 'foo bar' } const finalObject = Object.assign(firstObject, secondObject);
Using the spread operator
const firstObject = { __key: "a key", __src: "a src", } const secondObject = { moreData: 'foo bar' } const finalObject = { ...secondObject, ...firstObject };