isRxFlag

Benchmark created on


Setup

function rxFlags(x) {
		return x.toString().slice(x.toString().lastIndexOf("/") + 1);
	}
	
	const rx = /thing/img;

Test runner

Ready to run.

Testing in
TestOps/sec
indexOf
return rxFlags(rx).indexOf("m") !== -1
ready
loop
const s = rxFlags(rx);

for(let c of s) {
	if( c === "m")
	   return true;
}

return false;
ready
charcode
const s = rxFlags(rx);
const c = "m".charCodeAt(0);

for( let i = 0; i < s.length; i++) {
	if( s.charCodeAt(i) == c)
	   return true;
}

return false;
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.