String == vs Regex.test() (v2)

Revision 2 of this benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
String Compare (case insensitive)
var testString = "#form";

var stringGood = "#FORM";
var stringBad = "#not the RIGHT";

stringGood.toLowerCase() == testString && stringBad.toLowerCase() == testString;
ready
Regex Test (case insensitive)
var testString = "#form";

var regexGood = /^#form$/i;
var regexBad = /^#not the right$/i;

regexGood.test(testString) && regexBad.test(testString);
ready
strict
var testString = "#form";

var stringGood = "#FORM";
var stringBad = "#not the RIGHT";

stringGood.toLowerCase() === testString && stringBad.toLowerCase() === testString;
ready

Revisions

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