Check the string is Number in javascript?

Sometimes we need to check the string type. Here we will learn how to check the string is Number. to check the string we can make the one function in a common file.

Place the below function in your js file.

function isNumber(text){
  if(text) {  
    var reg =  new RegExp('[0-9]+$');
    return reg.test(text);
  }
  return false;
} 
console.log(isNumber(21323))

way to call the isNumber function.

console.log(isNumber(21323))

Output:-

true