Computer >> Computer tutorials >  >> Programming >> Javascript

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


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 −

<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>