Javascript 中的 POSITIVE_INFINITY函

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

描述

This is a special numeric value representing any value greater than Number.MAX_VALUE. This value is represented as "Infinity". It resembles an infinity in its mathematical behavior. For example, anything multiplied by POSITIVE_INFINITY is POSITIVE_INFINITY, and anything divided by POSITIVE_INFINITY is zero.

由于正无穷大是一个常数,因此它是number的只读属性。

语法

使用以下语法来使用active_infinity。

var val=Number.POSITIVE_INFINITY;

举例

尝试以下示例以了解如何使用posal_infinity。

<html>
   <head>      
      <script type="text/javascript">
         <!--
            function showValue() {
               var bigNumber=Number.MAX_VALUE * 2               
               if (bigNumber == Number.POSITIVE_INFINITY) {
                  alert("Value of bigNumber : " + bigNumber );
               }
            }
         //-->
      </script>      
   </head>
   
   <body>
      <p>Click the following to see the result:</p>      
      <form>
         <input type="button" value="Click Me" onclick="showValue();" />
      </form>      
   </body>
</html>

输出

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

技术教程推荐

左耳听风 -〔陈皓〕

趣谈Linux操作系统 -〔刘超〕

消息队列高手课 -〔李玥〕

浏览器工作原理与实践 -〔李兵〕

恋爱必修课 -〔李一帆〕

徐昊 · TDD项目实战70讲 -〔徐昊〕

遗留系统现代化实战 -〔姚琪琳〕

B端体验设计入门课 -〔林远宏(汤圆)〕

后端工程师的高阶面经 -〔邓明〕

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