Created
December 20, 2010 16:13
-
-
Save JamieMason/748572 to your computer and use it in GitHub Desktop.
Assert value is Number
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
/** | |
* Determine whether the supplied value's datatype is Number. | |
* Odd problems can occur eg: "1"+"6" is "16" not 7. | |
* @param {Mixed} value Could be a true number: 123, 12.00, or eg: "123", "12.00" | |
* @return {Boolean} Whether value's type is Number, eg: "123" would be false whereas 123 would be true. | |
*/ | |
function isNum(data) | |
{ | |
return !isNaN(parseFloat(data)) && typeof data !== 'string'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment