Home  >  Article  >  Web Front-end  >  Detailed explanation of the use of Number.NEGATIVE_INFINITY value in JavaScript_Basic knowledge

Detailed explanation of the use of Number.NEGATIVE_INFINITY value in JavaScript_Basic knowledge

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

This is a special value that represents a value less than Number.MIN_VALUE. This value is expressed as "negative infinity". This value is similar to infinity in its mathematical behavior. For example, anything multiplied by NEGATIVE_INFINITY is NEGATIVE_INFINITY, and anything divided by NEGATIVE_INFINITY is zero.

Because NEGATIVE_INFINITY is a constant, it is a read-only property of the number.
Grammar

You can access properties using the following syntax:

var val = Number.NEGATIVE_INFINITY;

Example:

Here is an example illustrating the usage of this attribute:

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

This will produce the following results:

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