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
12.3M/s
string .startsWith()
9.9M/s
regexp .test()
8.5M/s
string .match()
7.1M/s
View exact numbers
Test name Executions per second
indexOf === 0 12,333,521 Ops/sec
string .startsWith() 9,908,652 Ops/sec
regexp .test() 8,549,410 Ops/sec
string .match() 7,060,386 Ops/sec
Script Preparation code:
Tests: