Array indexOf vs String indexOf vs Object lookupFastest: Object lookup (2.0x faster)
38,088,264 ops/sec
35,817,700 ops/sec
19,310,602 ops/sec
Fastest: Object lookup (25.5x faster)
850,781,504 ops/sec
784,756,672 ops/sec
33,412,440 ops/sec
Results show median performance across all community submissions. Run this benchmark yourself to verify on your device.
| Test case name | Result |
|---|---|
| Array indexOf | |
| String indexOf | |
| Object lookup |
| Test name | Executions per second |
|---|---|
| ✓ String indexOf | 156,970,352 Ops/sec |
| Object lookup | 149,132,320 Ops/sec |
| Array indexOf | 78,815,256 Ops/sec |