Is positive integer (v6)

Revision 6 of this benchmark created by Sebastian Poreba on


Description

Fastest way if a variable contains an positive integer.

Preparation HTML

<script>
  var x = '123';
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Original (buggy)
parseInt(x) >= 0
ready
Using Equality
parseInt(x) === x && x > 0
ready
Regular Expression
/^[0-9]+$/.test(x)
ready
abs equal to original
(~~x) == x
ready

Revisions

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

  • Revision 1: published by Diogo Gomes on
  • Revision 3: published by Diogo Gomes on
  • Revision 6: published by Sebastian Poreba on