index vs charAt vs startsWith & endsWith vs slice vs regex test vs atFastest: regex test (1.6x faster)
11,439 ops/sec
9,701 ops/sec
9,282 ops/sec
9,175 ops/sec
7,191 ops/sec
7,185 ops/sec
Results show median performance across all community submissions. Run this benchmark yourself to verify on your device.
| Test case name | Result |
|---|---|
| index | |
| charAt | |
| startsWith & endsWith | |
| slice | |
| regex test | |
| at |
| Test name | Executions per second |
|---|---|
| ✓ slice | 2,541,703 Ops/sec |
| index | 2,489,456 Ops/sec |
| charAt | 2,453,752 Ops/sec |
| startsWith & endsWith | 2,346,453 Ops/sec |
| at | 121,011 Ops/sec |
| regex test | 50,963 Ops/sec |