Test name | Executions per second |
---|---|
Regex | 7998343.0 Ops/sec |
Array | 18085652.0 Ops/sec |
<!--your preparation HTML code goes here-->
const a = "/shorts/C0DLmWfdLGQ";
function isVideoPageR(type) {
const types = new RegExp("/" + (type || "(watch|short)"));
return types.test(a);
}
function isVideoPage(type) {
const types = type ? [type] : ["watch", "short"];
return types.some((type) => a.startsWith("/" + type));
}
isVideoPageR()
isVideoPage()