instanceof vs typeof vs typeof no function vs typeof and test attributeFastest: typeof (2.6x faster)
31,084,782 ops/sec
16,025,359 ops/sec
15,903,741 ops/sec
11,893,504 ops/sec
Fastest: typeof (9.4x faster)
1,466,747,520 ops/sec
1,208,324,096 ops/sec
1,100,445,696 ops/sec
156,356,032 ops/sec
Fastest: typeof (2.3x faster)
31,589,158 ops/sec
20,110,948 ops/sec
17,595,160 ops/sec
13,700,535 ops/sec
Fastest: typeof (1.2x faster)
71,960,696 ops/sec
69,432,776 ops/sec
65,042,920 ops/sec
60,818,016 ops/sec
Results show median performance across all community submissions. Run this benchmark yourself to verify on your device.
| Test case name | Result |
|---|---|
| instanceof | |
| typeof | |
| typeof no function | |
| typeof and test attribute |
| Test name | Executions per second |
|---|---|
| ✓ instanceof | 295,468,928 Ops/sec |
| typeof no function | 284,713,824 Ops/sec |
| typeof and test attribute | 273,132,032 Ops/sec |
| typeof | 268,715,296 Ops/sec |