×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Javascript
Posted by: Paul Zz
Added: Jan 22, 2017 6:48 AM
Modified: Feb 21, 2017 4:43 AM
Views: 7
  1. /**
  2.  * Returns true if the entire input value is a valid number or float.
  3.  * @example
  4.  * isNumber('123') // true <br>
  5.  * isNumber('123foo') // false <br>
  6.  * isNumber('123.45') // true <br>
  7.  * @param {*} num Any type
  8.  * @returns {Boolean} Remember, the function returns true if input is both '123' or 123
  9.  */
  10. function isNumber(num){
  11.     return !isNaN(num) && isFinite(num);
  12. }