How can I check if a variable is currently an integer type? I\'ve looked for some sort of resource for this and I think the === operator is important, but I\'m not sure how
A number is an integer if its modulo %1 is 0-
function isInt(n){ return (typeof n== 'number' && n%1== 0); }
This is only as good as javascript gets- say +- ten to the 15th.
isInt(Math.pow(2,50)+.1) returns true, as does Math.pow(2,50)+.1 == Math.pow(2,50)
isInt(Math.pow(2,50)+.1)
true
Math.pow(2,50)+.1 == Math.pow(2,50)