Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Object spread vs Object.assign vs simple assignement
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36
Browser:
Chrome 142
Operating system:
Linux
Device Platform:
Desktop
Date tested:
4 months ago
Test name
Executions per second
spread
51270244.0 Ops/sec
Object.assign
75381456.0 Ops/sec
manually assigning
98044008.0 Ops/sec
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
const firstObject = {} firstObject.key1 = 'Hello world'; firstObject.key2 = 'foo bar'; firstObject.key3 = '42'; firstObject.key4 = 'Hitch Hikers Guide to the Galaxy'; const secondObject = {} firstObject.key3 = 'Hello world'; firstObject.key4 = 'foo bar'; firstObject.key5 = '42'; firstObject.key6 = 'Hitch Hikers Guide to the Galaxy';
Tests:
spread
const firstObject = {} firstObject.key1 = 'Hello world'; firstObject.key2 = 'foo bar'; firstObject.key3 = '42'; firstObject.key4 = 'Hitch Hikers Guide to the Galaxy'; const secondObject = {} firstObject.key3 = 'Hello world'; firstObject.key4 = 'foo bar'; firstObject.key5 = '42'; firstObject.key6 = 'Hitch Hikers Guide to the Galaxy'; const output = { ...firstObject, ...secondObject }
Object.assign
const firstObject = {} firstObject.key1 = 'Hello world'; firstObject.key2 = 'foo bar'; firstObject.key3 = '42'; firstObject.key4 = 'Hitch Hikers Guide to the Galaxy'; const secondObject = {} firstObject.key3 = 'Hello world'; firstObject.key4 = 'foo bar'; firstObject.key5 = '42'; firstObject.key6 = 'Hitch Hikers Guide to the Galaxy'; // Note this does modify and return the first object, doesn't create a new one const output = Object.assign(firstObject, secondObject);
manually assigning
const firstObject = {} firstObject.key1 = 'Hello world'; firstObject.key2 = 'foo bar'; firstObject.key3 = '42'; firstObject.key4 = 'Hitch Hikers Guide to the Galaxy'; const secondObject = {} firstObject.key3 = 'Hello world'; firstObject.key4 = 'foo bar'; firstObject.key5 = '42'; firstObject.key6 = 'Hitch Hikers Guide to the Galaxy'; // Note this does modify and return the first object, doesn't create a new one for (const key in secondObject) { firstObject[key] = secondObject[key] } const output = firstObject;