什么是JavaScript中的Number.NEGATIVE_INFINITY常量?

Number.NEGATIVE_INFINITY是一个特殊的数值,表示小于Number.MIN_VALUE的值。该值表示为“ -Infinity”。它的数学行为类似于无穷大。

示例

您可以尝试运行以下代码以了解如何使用Number.NEGATIVE_INFINITY常量-

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