text.includes() vs regex.test() vs string.match() vs string.indexOf() vs string.indexOf() !== -1 vs string.indexOf() != -1| Test case name | Result |
|---|---|
| text.includes() | |
| regex.test() | |
| string.match() | |
| string.indexOf() | |
| string.indexOf() !== -1 | |
| string.indexOf() != -1 |
| Test name | Executions per second |
|---|---|
| ✓ string.indexOf() != -1 | 57,929,040 Ops/sec |
| string.indexOf() | 57,198,644 Ops/sec |
| string.indexOf() !== -1 | 56,758,340 Ops/sec |
| text.includes() | 55,165,836 Ops/sec |
| regex.test() | 9,927,778 Ops/sec |
| string.match() | 7,203,115 Ops/sec |