Last active
December 16, 2015 16:19
-
-
Save BartlomiejSkwira/5462011 to your computer and use it in GitHub Desktop.
Check if value is integer in Javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//check a remainder when dividing by 1: | |
function isInt(n) { | |
return n % 1 === 0; | |
} | |
//If you don't know that the argument is a number- | |
function isInt(n) { | |
return !isNaN(n) && n % 1 == 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment