Using the spread operator vs Using Object.assign vs Manually copying properties vs Create new object while copying vs Create new object from scratch vs StructuredClone vs JSONFastest: Create new object from scratch (201.6x faster)
162,857,216 ops/sec
159,094,688 ops/sec
146,901,056 ops/sec
49,019,032 ops/sec
12,917,174 ops/sec
3,130,641 ops/sec
807,705 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 | |
| StructuredClone | |
| JSON |
| Test name | Executions per second |
|---|---|
| ✓ Create new object from scratch | 127,190,776 Ops/sec |
| Manually copying properties | 119,866,712 Ops/sec |
| Create new object while copying | 119,516,416 Ops/sec |
| Using the spread operator | 40,543,332 Ops/sec |
| Using Object.assign | 10,563,756 Ops/sec |
| JSON | 2,229,924 Ops/sec |
| StructuredClone | 331,637 Ops/sec |