Home > Web Front-end > JS Tutorial > 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
Release: 2016-05-16 15:56:29
Original
1440 people have browsed it

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;

Copy after login

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>

Copy after login

This will produce the following results:

Value of val : -Infinity
Copy after login


Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template