lowercase vs regex vs eqi

Edit on GitHub

Setup

var x = "LABEL";
function eqi(s1, c) { return s1 === c || s1.toUpperCase() === c; }
var i = 0;

Tests

  • lowercase

    x.toLowerCase() === "label" && i++;
  • regex

    /^LABEL$/i.test(x) && i++;
  • eqi

    eqi(x, "LABEL") && i++;