Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36
Chrome 128
Linux
Desktop
2 years ago
Benchmark.js
indexOf === 0
7.6M/s
string .startsWith()
5.3M/s
regexp .test()
4.3M/s
string .match()
3.3M/s
View exact numbers
Test name Executions per second
indexOf === 0 7,569,850 Ops/sec
string .startsWith() 5,294,535 Ops/sec
regexp .test() 4,306,856 Ops/sec
string .match() 3,272,186 Ops/sec
Script Preparation code:
Tests: