by @kodeazy

How to check a variable is number or string in javascript?

Home » javascript » How to check a variable is number or string in javascript?
  • To check whether a variable is string or not we use isNaN function.
  • Below is the syntax.
  • isNaN('-234').
  • returns true if the data inside the above function is not a number else returns false.
  • Below is the sample example.

    var numberOrString=isNaN('-234');
    console.log(numberOrString);

    Output:

    false