1// native returns true if the variable does NOT contain a valid number
2isNaN(num)
3
4// can be wrapped for making simple and readable
5function isNumeric(num){
6 return !isNaN(num)
7}
8
9isNumeric(123) // true
10isNumeric('123') // true
11isNumeric('1e10000') // true (This translates to Infinity, which is a number)
12isNumeric('foo') // false
13isNumeric('10px') // false
1isNaN(num) // returns true if the variable does NOT contain a valid number
2
3isNaN(123) // false
4isNaN('123') // false
5isNaN('1e10000') // false (This translates to Infinity, which is a number)
6isNaN('foo') // true
7isNaN('10px') // true
1// The Number.isInteger() checks to see if the passed value is an integer
2// Returns true or false
3
4Number.isInteger(2); //True
5Number.isInteger(90); //True
6Number.isInteger("37"); //False
7Number.isInteger(false); //false
1function isInt(str) {
2 return !isNaN(str) && Number.isInteger(parseFloat(str));
3}