RegEx.test vs String.includes vs String.match vs == vs === known length vs startsWithFastest: === known length (19.4x faster)
189,410,976 ops/sec
183,971,360 ops/sec
181,894,848 ops/sec
91,959,544 ops/sec
51,608,328 ops/sec
9,741,514 ops/sec
Results show median performance across all community submissions. Run this benchmark yourself to verify on your device.
| Test case name | Result |
|---|---|
| RegEx.test | |
| String.includes | |
| String.match | |
| == | |
| === known length | |
| startsWith |
| Test name | Executions per second |
|---|---|
| ✓ String.includes | 204,456,704 Ops/sec |
| === known length | 199,500,192 Ops/sec |
| == | 181,193,424 Ops/sec |
| startsWith | 90,295,720 Ops/sec |
| RegEx.test | 54,454,748 Ops/sec |
| String.match | 11,466,605 Ops/sec |