text.includes() vs regex.test() vs string.match() vs string.indexOf()Fastest: text.includes() (2.5x faster)
30,452,560 ops/sec
30,382,360 ops/sec
15,396,231 ops/sec
12,373,802 ops/sec
Fastest: string.indexOf() (69.3x faster)
1,093,978,752 ops/sec
1,071,030,592 ops/sec
25,311,298 ops/sec
15,790,091 ops/sec
Fastest: string.indexOf() (16.2x faster)
415,250,304 ops/sec
386,130,560 ops/sec
125,371,240 ops/sec
25,697,058 ops/sec
Fastest: text.includes() (3.2x faster)
20,206,092 ops/sec
19,015,372 ops/sec
8,194,358 ops/sec
6,402,257 ops/sec
Fastest: text.includes() (2.2x faster)
13,457,314 ops/sec
13,055,995 ops/sec
8,369,469 ops/sec
6,051,253 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 |
|---|---|
| ✓ string.indexOf() | 200,737,072 Ops/sec |
| text.includes() | 186,534,704 Ops/sec |
| regex.test() | 25,641,002 Ops/sec |
| string.match() | 18,122,838 Ops/sec |