Run details:
Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36 OPR/95.0.0.0
Opera 95
Windows 7
Desktop
one year ago
Benchmark.js
indexOf === 0
5.3M/s
string .startsWith()
3.4M/s
regexp .test()
2.7M/s
string .match()
2.4M/s
View exact numbers
Test name Executions per second
indexOf === 0 5,299,470 Ops/sec
string .startsWith() 3,358,415 Ops/sec
regexp .test() 2,664,296 Ops/sec
string .match() 2,427,510 Ops/sec
Script Preparation code:
Tests: