Integer Validity (v26)

Revision 26 of this benchmark created on


Setup

var a = 12;
    var b = 34.5;
    var c = Infinity;
    var x = '343abc';
    var y = '234';

Test runner

Ready to run.

Testing in
TestOps/sec
Typeof and modulus operator
(typeof a === 'number' && (a % 1) === 0);
(typeof b === 'number' && (b % 1) === 0);
(typeof c === 'number' && (c % 1) === 0);
(typeof x === 'number' && (x % 1) === 0);
(typeof y === 'number' && (y % 1) === 0);
ready
Using parseInt
(a == parseInt(a));
(b == parseInt(b));
(c == parseInt(c));
(x == parseInt(x));
(y == parseInt(y));
ready

Revisions

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