regexp .test() vs string .match() vs indexOf === 0 vs string .startsWith() vs regexp .test() failure vs string .match() failure vs indexOf === 0 failure vs string .startsWith() failure| Test case name | Result |
|---|---|
| regexp .test() | |
| string .match() | |
| indexOf === 0 | |
| string .startsWith() | |
| regexp .test() failure | |
| string .match() failure | |
| indexOf === 0 failure | |
| string .startsWith() failure |
| Test name | Executions per second |
|---|---|
| ✓ indexOf === 0 | 26,731,626 Ops/sec |
| indexOf === 0 failure | 26,399,540 Ops/sec |
| string .startsWith() | 19,714,600 Ops/sec |
| string .startsWith() failure | 19,662,736 Ops/sec |
| regexp .test() failure | 17,556,494 Ops/sec |
| regexp .test() | 17,450,186 Ops/sec |
| string .match() failure | 14,471,784 Ops/sec |
| string .match() | 14,155,647 Ops/sec |