Skip to content

Instantly share code, notes, and snippets.

@JamieMason
Created December 20, 2010 16:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save JamieMason/748572 to your computer and use it in GitHub Desktop.
Save JamieMason/748572 to your computer and use it in GitHub Desktop.
Assert value is Number
/**
* 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