Testing for numeric values in javascript
var isNumber = function (n) {
return !isNaN(parseFloat(n)) && isFinite(n);
};
Pass in strings, or any other object in javascript.
Check out all these passing unit tests!
Source: This Stack Overflow answer
Written by travis
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Javascript
Authors
Related Tags
#javascript
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#