Not empty lodash.head() vs Not empty [0] vs Empty lodash.head() vs Empty [0] vs [0] with check vs [0] with null checkFastest: Not empty [0] (3.4x faster)
24,496,080 ops/sec
23,744,198 ops/sec
10,185,620 ops/sec
9,825,416 ops/sec
9,733,877 ops/sec
7,206,290 ops/sec
Results show median performance across all community submissions. Run this benchmark yourself to verify on your device.
| Test case name | Result |
|---|---|
| Not empty lodash.head() | |
| Not empty [0] | |
| Empty lodash.head() | |
| Empty [0] | |
| [0] with check | |
| [0] with null check |
| Test name | Executions per second |
|---|---|
| ✓ Not empty [0] | 156,071,376 Ops/sec |
| Empty [0] | 153,779,568 Ops/sec |
| Empty lodash.head() | 146,354,288 Ops/sec |
| Not empty lodash.head() | 140,225,968 Ops/sec |
| [0] with null check | 109,482,064 Ops/sec |
| [0] with check | 107,028,608 Ops/sec |