undefined vs typeof vs in vs hasOwnProperty vs boolFastest: typeof (2.6x faster)
28,530,258 ops/sec
28,447,060 ops/sec
28,251,338 ops/sec
24,852,876 ops/sec
11,143,366 ops/sec
Fastest: typeof (1.2x faster)
973,419,200 ops/sec
900,442,496 ops/sec
873,620,032 ops/sec
863,692,608 ops/sec
829,036,352 ops/sec
Fastest: typeof (2.8x faster)
31,798,612 ops/sec
31,601,492 ops/sec
31,559,964 ops/sec
31,145,356 ops/sec
11,197,392 ops/sec
Fastest: typeof (1.7x faster)
254,636,880 ops/sec
252,883,760 ops/sec
242,479,632 ops/sec
234,631,296 ops/sec
152,875,264 ops/sec
Fastest: typeof (2.5x faster)
18,676,362 ops/sec
18,654,818 ops/sec
18,471,200 ops/sec
16,105,794 ops/sec
7,504,119 ops/sec
Results show median performance across all community submissions. Run this benchmark yourself to verify on your device.
| Test case name | Result |
|---|---|
| undefined | |
| typeof | |
| in | |
| hasOwnProperty | |
| bool |
| Test name | Executions per second |
|---|---|
| ✓ in | 730,780,288 Ops/sec |
| hasOwnProperty | 708,181,056 Ops/sec |
| undefined | 694,998,080 Ops/sec |
| typeof | 663,690,048 Ops/sec |
| bool | 657,673,536 Ops/sec |