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
Using the spread operator with constant inside
20.9M/s
Using Object.assign
11.4M/s
Using the spread operator
10.4M/s
View exact numbers
Test name
Executions per second
✓
Using the spread operator with constant inside
20,906,868 Ops/sec
Using Object.assign
11,405,674 Ops/sec
Using the spread operator
10,418,629 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 };