Using the spread operator vs Using Object.assign vs Using For-In loop vs Using For-In loop with hasOwnPropertyFastest: Using For-In loop (8.6x faster)
58,622,980 ops/sec
34,328,856 ops/sec
10,773,756 ops/sec
6,839,729 ops/sec
Fastest: Using For-In loop (2.3x faster)
23,674,884 ops/sec
16,963,084 ops/sec
11,926,582 ops/sec
10,196,156 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 | |
| Using For-In loop | |
| Using For-In loop with hasOwnProperty |
| Test name | Executions per second |
|---|---|
| ✓ Using For-In loop | 16,262,519 Ops/sec |
| Using Object.assign | 13,491,494 Ops/sec |
| Using For-In loop with hasOwnProperty | 10,132,150 Ops/sec |
| Using the spread operator | 9,416,741 Ops/sec |