What are MAX_VALUE and MIN_VALUE in JavaScript?



The Number.MAX_VALUE property belongs to the static Number object. It represents constants for the largest possible positive numbers that JavaScript can work with.

The Number.MIN_VALUE property belongs to the static Number object. It represents constants for the smallest possible positive numbers that JavaScript can work with.

Example

You can try to run the following code to learn about the MAX and MIN value in JavaScript −

Live Demo

<html>
   <head>
      <script>
         function showMinValue() {
            var val = Number.MIN_VALUE;
            alert("Value of Number.MIN_VALUE : " + val );
         }
         function showMaxValue() {
            var val = Number.MAX_VALUE;
            alert("Value of Number.MAX_VALUE : " + val );
         }
      </script>
   </head>

   <body>
      <p>Click the following to see the result:</p>
      <form>
         <input type="button" value="MIN" onclick="showMinValue();" />
         <input type="button" value="MAX" onclick="showMaxValue();" />
      </form>
   </body>
</html>

Advertisements