DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Jason has posted 22 posts at DZone. View Full User Profile

JavaScript IsNumber Function

02.20.2009
| 18279 views |
  • submit to reddit
        JavaScript function that determines if a variable is an actual Number object and not NaN or +/- Infinity.

function isNumber(x) 
{ 
  return ( (typeof x === typeof 1) && (null !== x) && isFinite(x) );
}