HTML Preparation code:
AخA
 
1
var string = "passw)odas4gsdfsdf";
Script Preparation code:
 
var string = "passw)odas4gsdfsdf";
Tests:
  • Regex

     
    /^[a-z0-9]+$/i.test(string)
  • charCodeAt

    x
     
    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(string)
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Regex
    charCodeAt

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 2 months ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Chrome 131 on Mac OS X 10.15.7
View result in a separate tab
Test name Executions per second
Regex 21788476.0 Ops/sec
charCodeAt 38893104.0 Ops/sec