Created
October 27, 2015 13:01
-
-
Save andreasvirkus/e06845f97730cea46b30 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/** | |
* 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