_.union vs Set() vs Set() convert back to arrayFastest: Set() (1.5x faster)
5,982,972 ops/sec
4,209,372 ops/sec
3,921,848 ops/sec
Fastest: _.union (2.0x faster)
4,158,813 ops/sec
2,940,596 ops/sec
2,051,553 ops/sec
Results show median performance across all community submissions. Run this benchmark yourself to verify on your device.
| Test case name | Result |
|---|---|
| _.union | |
| Set() | |
| Set() convert back to array |
| Test name | Executions per second |
|---|---|
| ✓ Set() | 12,974,650 Ops/sec |
| Set() convert back to array | 8,639,212 Ops/sec |
| _.union | 8,511,797 Ops/sec |