Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36
Chrome 120
Windows
Desktop
2 years ago
Benchmark.js
indexOf === 0
8.0M/s
string .startsWith()
5.5M/s
regexp .test()
4.9M/s
string .match()
4.2M/s
View exact numbers
Test name Executions per second
indexOf === 0 8,008,164 Ops/sec
string .startsWith() 5,504,868 Ops/sec
regexp .test() 4,943,704 Ops/sec
string .match() 4,199,613 Ops/sec
Script Preparation code:
Tests: