text.includes() vs regex.test() vs string.match() vs string.indexOf()Fastest: text.includes() (2.7x faster)
26,727,032 ops/sec
26,363,750 ops/sec
14,873,630 ops/sec
9,800,356 ops/sec
Results show median performance across all community submissions. Run this benchmark yourself to verify on your device.
| Test case name | Result |
|---|---|
| text.includes() | |
| regex.test() | |
| string.match() | |
| string.indexOf() |
| Test name | Executions per second |
|---|---|
| ✓ text.includes() | 698,914,048 Ops/sec |
| string.indexOf() | 684,237,376 Ops/sec |
| regex.test() | 13,969,979 Ops/sec |
| string.match() | 5,263,850 Ops/sec |