Home  >  Article  >  Web Front-end  >  JavaScript中Number.NEGATIVE_INFINITY值的使用详解_基础知识

JavaScript中Number.NEGATIVE_INFINITY值的使用详解_基础知识

WBOY
WBOYOriginal
2016-05-16 15:56:291336browse

 这是代表一个的值小于Number.MIN_VALUE一个特殊数值。此值被表示为“负无穷”。此值类似于在其数学行为的无穷大。例如,任何事情乘以NEGATIVE_INFINITY是NEGATIVE_INFINITY,以及任何除以NEGATIVE_INFINITY的值都为零。

因为NEGATIVE_INFINITY是一个常数,它是数的只读属性。
语法

您可以使用以下语法访问属性:

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>

这将产生以下结果:

Value of val : -Infinity

 

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn