Skip to content

Instantly share code, notes, and snippets.

@andreasvirkus
Created October 27, 2015 13:01
Show Gist options
  • Save andreasvirkus/e06845f97730cea46b30 to your computer and use it in GitHub Desktop.
Save andreasvirkus/e06845f97730cea46b30 to your computer and use it in GitHub Desktop.
/**
* A simple type check for integers
*
* Interprets integer valued strings as integers (e.g. '22' will return true).
*
* @param value
* @returns {boolean}
*/
function isInt(value) {
var x;
if (isNaN(value)) {
return false;
}
x = parseFloat(value);
return (x | 0) === x;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment