Skip to content

Instantly share code, notes, and snippets.

@BartlomiejSkwira
Last active December 16, 2015 16:19
Show Gist options
  • Save BartlomiejSkwira/5462011 to your computer and use it in GitHub Desktop.
Save BartlomiejSkwira/5462011 to your computer and use it in GitHub Desktop.
Check if value is integer in Javascript
//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