Using the spread operator vs Using Object.assign vs Manually copying properties vs Create new object while copying vs Create new object from scratchFastest: Create new object while copying (22.2x faster)
168,059,488 ops/sec
167,285,760 ops/sec
161,117,184 ops/sec
45,533,972 ops/sec
7,570,570 ops/sec
Fastest: Create new object from scratch (41.2x faster)
278,225,696 ops/sec
185,548,656 ops/sec
180,721,968 ops/sec
34,826,072 ops/sec
6,760,750 ops/sec
Results show median performance across all community submissions. Run this benchmark yourself to verify on your device.
| Test case name | Result |
|---|---|
| Using the spread operator | |
| Using Object.assign | |
| Manually copying properties | |
| Create new object while copying | |
| Create new object from scratch |
| Test name | Executions per second |
|---|---|
| ✓ Manually copying properties | 132,414,600 Ops/sec |
| Create new object from scratch | 130,561,976 Ops/sec |
| Create new object while copying | 127,349,336 Ops/sec |
| Using the spread operator | 43,787,276 Ops/sec |
| Using Object.assign | 10,636,184 Ops/sec |