instanceof vs string type vs string type + undefined vs propertyFastest: string type (2.5x faster)
21,266,100 ops/sec
9,830,011 ops/sec
8,758,757 ops/sec
8,618,235 ops/sec
Fastest: string type (8.0x faster)
1,352,126,080 ops/sec
1,323,798,016 ops/sec
1,292,818,048 ops/sec
168,513,024 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 |
| Test name | Executions per second |
|---|---|
| ✓ string type + undefined | 151,225,232 Ops/sec |
| property | 147,963,712 Ops/sec |
| instanceof | 144,025,936 Ops/sec |
| string type | 135,276,976 Ops/sec |