instanceof vs string type vs string type + undefined vs property vs constructor comparisonFastest: string type (2.5x faster)
21,013,596 ops/sec
8,854,780 ops/sec
8,835,674 ops/sec
8,332,293 ops/sec
8,282,611 ops/sec
Results show median performance across all community submissions. Run this benchmark yourself to verify on your device.
| Test case name | Result |
|---|---|
| instanceof | |
| string type | |
| string type + undefined | |
| property | |
| constructor comparison |
| Test name | Executions per second |
|---|---|
| ✓ constructor comparison | 184,690,880 Ops/sec |
| string type + undefined | 184,613,104 Ops/sec |
| instanceof | 181,958,368 Ops/sec |
| string type | 180,586,288 Ops/sec |
| property | 166,633,696 Ops/sec |