Skip to content

Instantly share code, notes, and snippets.

@makeusabrew
Forked from JamieMason/isNumber.js
Created February 15, 2011 12:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save makeusabrew/827477 to your computer and use it in GitHub Desktop.
Save makeusabrew/827477 to your computer and use it in GitHub Desktop.
/**
* Determine whether the supplied value's datatype is Number
* @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 isNumber(data)
{
var num = parseFloat(data);
return ! isNaN(parseFloat(data)) && num.toString() === data.toString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment