isAlphanumeric

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
regex
function isAlphanumeric(char) {
    return /^[a-zA-Z0-9]$/.test(char);
}

isAlphanumeric('a');
isAlphanumeric(' ');
ready
charCodeAt
function isAlphanumeric(char) {
    const code = char.charCodeAt(0);
    return (code >= 48 && code <= 57) ||  // (0-9)
           (code >= 65 && code <= 90) ||  // (A-Z)
           (code >= 97 && code <= 122);   //  (a-z)
}

isAlphanumeric('a');
isAlphanumeric(' ');
ready

Revisions

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