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
11.0M/s
regexp .test()
7.7M/s
string .startsWith()
7.0M/s
string .match()
6.2M/s
View exact numbers
Test name Executions per second
indexOf === 0 10,952,281 Ops/sec
regexp .test() 7,661,521 Ops/sec
string .startsWith() 6,999,084 Ops/sec
string .match() 6,230,984 Ops/sec
Script Preparation code:
Tests: