!! (number) vs Boolean() (number) vs ternary (number) vs !! (string) vs Boolean() (string) vs ternary (string)Fastest: !! (number) (11.6x faster)
189,288,528 ops/sec
181,303,104 ops/sec
179,778,224 ops/sec
179,205,808 ops/sec
16,501,763 ops/sec
16,360,890 ops/sec
Results show median performance across all community submissions. Run this benchmark yourself to verify on your device.
| Test case name | Result |
|---|---|
| !! (number) | |
| Boolean() (number) | |
| ternary (number) | |
| !! (string) | |
| Boolean() (string) | |
| ternary (string) |
| Test name | Executions per second |
|---|---|
| ✓ !! (number) | 220,420,480 Ops/sec |
| ternary (string) | 219,856,304 Ops/sec |
| !! (string) | 214,078,304 Ops/sec |
| ternary (number) | 210,615,312 Ops/sec |
| Boolean() (number) | 204,401,040 Ops/sec |
| Boolean() (string) | 197,122,288 Ops/sec |