Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Ways of returning a derived object 2
(version: 1)
Comparing performance of:
...rest vs Spread original vs Don't destructure vs Object.assign vs Assign to spread individually
Created:
2 years ago
by:
Registered User
Jump to the latest result
Tests:
...rest
const orig = { value1: "Hello", value2: 5, value3: 6 }; const fn = x => x + 1; const { value2, value3, ...rest} = orig; const out = { ...rest, value2: fn(value2), value3: fn(value3)};
Spread original
const orig = { value1: "Hello", value2: 5, value3: 6 }; const fn = x => x + 1; const { value2, value3 } = orig; const out = { ...orig, value2: fn(value2), value3: fn(value3)};
Don't destructure
const orig = { value1: "Hello", value2: 5, value3: 6 }; const fn = x => x + 1; const out = { ...orig, value2: fn(orig.value2), value3: fn(orig.value3)};
Object.assign
const orig = { value1: "Hello", value2: 5, value3: 6 }; const fn = x => x + 1; const out = Object.assign({}, orig, { value2: fn(orig.value2), value3: fn(orig.value3)});
Assign to spread individually
const orig = { value1: "Hello", value2: 5, value3: 6 }; const fn = x => x + 1; const { value2, value3, ...rest} = orig; rest.value2 = fn(value2); rest.value3 = fn(value3);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (5)
Previous results
Fork
Test case name
Result
...rest
Spread original
Don't destructure
Object.assign
Assign to spread individually
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Comments
Confirm delete:
Do you really want to delete benchmark?