Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36
Chrome 126
Windows
Desktop
2 years ago
Benchmark.js
indexOf === 0
9.2M/s
string .startsWith()
7.0M/s
regexp .test()
5.7M/s
string .match()
4.6M/s
View exact numbers
Test name Executions per second
indexOf === 0 9,187,203 Ops/sec
string .startsWith() 7,017,082 Ops/sec
regexp .test() 5,735,322 Ops/sec
string .match() 4,643,712 Ops/sec
Script Preparation code:
Tests: