isdigit

Benchmark created on


Preparation HTML

<script>
  var digitRe = /[0-9]/;
  
  var digitChars = '';
  for (i = '0'.charCodeAt(0); i <= '9'.charCodeAt(0); i += 1) {
   digitChars += String.fromCharCode(i);
  }
  
  var ch = String.fromCharCode(48 + Math.random() * 10);
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
if
var p = ((ch >= '0') && (ch <= '9'));
ready
indexOf
var q = digitChars.indexOf(ch) !== -1;
ready
regex
var s = !! ch.match(digitRe);
ready

Revisions

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