slice vs substring vs [] vs charAt vs charCodeAtFastest: substring (1.2x faster)
150,881,088 ops/sec
147,799,072 ops/sec
146,852,864 ops/sec
139,736,896 ops/sec
124,536,176 ops/sec
Results show median performance across all community submissions. Run this benchmark yourself to verify on your device.
| Test case name | Result |
|---|---|
| slice | |
| substring | |
| [] | |
| charAt | |
| charCodeAt |
| Test name | Executions per second |
|---|---|
| ✓ charAt | 137,195,088 Ops/sec |
| charCodeAt | 127,126,464 Ops/sec |
| slice | 120,907,600 Ops/sec |
| substring | 115,170,336 Ops/sec |
| [] | 112,234,440 Ops/sec |