alphanum

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
if
const CHARS = new Set("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
function isAlphanumeric(char) {
    return CHARS.has(char);
}


isAlphanumeric("thisisalongstring8989IDONNTKNOW")
ready
loop
function isAlphaNumeric(str) {
  var code, i, len;

  for (i = 0, len = str.length; i < len; i++) {
    code = str.charCodeAt(i);
    if (!(code > 47 && code < 58) && // numeric (0-9)
        !(code > 64 && code < 91) && // upper alpha (A-Z)
        !(code > 96 && code < 123)) { // lower alpha (a-z)
      return false;
    }
  }
  return true;
};

isAlphanumeric("thisisalongstring8989IDONNTKNOW")
ready

Revisions

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