Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36
Chrome 120
Linux
Desktop
2 years ago
Benchmark.js
indexOf === 0
24.0M/s
string .startsWith()
16.7M/s
regexp .test()
15.8M/s
string .match()
12.6M/s
View exact numbers
Test name Executions per second
indexOf === 0 24,009,718 Ops/sec
string .startsWith() 16,696,462 Ops/sec
regexp .test() 15,773,309 Ops/sec
string .match() 12,574,977 Ops/sec
Script Preparation code:
Tests: