How to check whether a value is a number in JavaScript?

JavascriptWeb DevelopmentFront End Technology

To check whether a value is a number in JavaScript, use the isInteger() method. This method checks whether the value is a number or not.

Example

You can try to run the following code to check the value is a number or not −

Live Demo

<html>
   <head>
      <title>JavaScript isInteger() Method </title>
   </head>

   <body>
      <script>
         document.write(Number.isInteger(30));
         document.write("<br>"+Number.isInteger(true));
         document.write("<br>"+Number.isInteger(false));
         document.write("<br>"+Number.isInteger(-30));
      </script>
   </body>
</html>
raja
Published on 18-Jan-2018 11:50:41
Advertisements