Answers for "check if is number js'"

13

javascript check if string is number

if (typeof myVar === 'string'){
    //I am indeed a string
}
Posted by: Guest on July-23-2019
0

javascript check if number

function isNumber(n) { return /^-?[\d.]+(?:e-?\d+)?$/.test(n); } 

------------------------

isNumber('123'); // true  
isNumber('123abc'); // false  
isNumber(5); // true  
isNumber('q345'); // false
isNumber(null); // false
isNumber(undefined); // false
isNumber(false); // false
isNumber('   '); // false
Posted by: Guest on May-21-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language