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

What is Number.NEGATIVE_INFINITY constant in JavaScript?


Number.NEGATIVE_INFINITY is a special numeric value representing a value less than Number.MIN_VALUE. This value is represented as "-Infinity". It resembles infinity in its mathematical behavior.

Example

You can try to run the following code to learn how to work with Number.NEGATIVE_INFINITY constant −

<html>
   <head>
      <script>
         <!--
            function showValue() {
               var smallNumber = (-Number.MAX_VALUE) * 2
               if (smallNumber == Number.NEGATIVE_INFINITY) {
                  alert("Value of smallNumber : " + smallNumber );
               }
            }
         //-->
      </script>
   </head>

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