Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36
Chrome 123
Windows
Desktop
2 years ago
Benchmark.js
indexOf === 0
9.4M/s
string .startsWith()
7.3M/s
regexp .test()
6.4M/s
string .match()
5.4M/s
View exact numbers
Test name Executions per second
indexOf === 0 9,384,467 Ops/sec
string .startsWith() 7,327,528 Ops/sec
regexp .test() 6,380,733 Ops/sec
string .match() 5,373,762 Ops/sec
Script Preparation code:
Tests: