javascript - How do I check that a number is float or integer? -


how find number float or integer?

1.25 --> float   1 --> integer   0 --> integer   0.25 --> float 

check remainder when dividing 1:

function isint(n) {    return n % 1 === 0; } 

if don't know argument number need 2 tests:

function isint(n){     return number(n) === n && n % 1 === 0; }  function isfloat(n){     return number(n) === n && n % 1 !== 0; } 

Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -