What is Number.NEGATIVE_INFINITY constant in JavaScript?

JavascriptWeb DevelopmentFront End Technology

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 −

Live Demo

<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>
raja
Published on 18-Jan-2018 11:56:19
Advertisements