Integer Validity (v37)

Revision 37 of this benchmark created on


Setup

var a = 12;
    var b = 34.5;
    var c = Infinity;
    var d = 'blah';
    var e = NaN;

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 d==='number' && (d%1)===0);
(typeof e==='number' && (e%1)===0);
ready
Using parseInt
(a == parseInt(a));
(b == parseInt(b));
(c == parseInt(c));
(d == parseInt(d));
(e == parseInt(e));
ready
Typeof and isNaN
(typeof a==='number' && !isNaN(a));
(typeof b==='number' && !isNaN(b));
(typeof c==='number' && !isNaN(c));
(typeof d==='number' && !isNaN(d));
(typeof e==='number' && !isNaN(e));
ready

Revisions

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