Javascript 中的 NEGATIVE_INFINITY函

首页 / JavaScript入门教程 / Javascript 中的 NEGATIVE_INFINITY函

描述

This is a special numeric value representing a value less than Number.MIN_VALUE. This value is represented as "-Infinity". It resembles an infinity in its mathematical behavior. For example, anything multiplied by NEGATIVE_INFINITY is NEGATIVE_INFINITY, and anything divided by NEGATIVE_INFINITY is zero.

因为负无穷大是一个常量,所以它是number的只读属性。

链接:https://www.learnfk.comhttps://www.learnfk.com/javascript/number-negative-infinity.html

来源:LearnFk无涯教程网

语法

使用负无穷大的语法如下所示:−

无涯教程网

var val=Number.NEGATIVE_INFINITY;

举例

尝试以下示例。

<html>
   <head>      
      <script type="text/javascript">
         <!--
            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>

输出

祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)

技术教程推荐

深入剖析Kubernetes -〔张磊〕

代码精进之路 -〔范学雷〕

MySQL实战45讲 -〔林晓斌〕

数据分析实战45讲 -〔陈旸〕

玩转Spring全家桶 -〔丁雪丰〕

设计模式之美 -〔王争〕

分布式协议与算法实战 -〔韩健〕

互联网人的英语私教课 -〔陈亦峰〕

高并发系统实战课 -〔徐长龙〕

好记忆不如烂笔头。留下您的足迹吧 :)