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
1function isNumeric(num){
2 return !isNaN(num)
3}
4isNumeric("23.33"); //true, checking if string is a number.
1function isInt(str) {
2 return !isNaN(str) && Number.isInteger(parseFloat(str));
3}
1var myString = "abc123";
2var otherString = "123";
3/* isInterger() checks if an value repersents an int */
4
5Number.isInteger(myString); //returns false
6Number.isInteger(otherString); //returns true