Home >Web Front-end >JS Tutorial >Introduction to the use of POSITIVE_INFINITY value in JavaScript_Basic knowledge

Introduction to the use of POSITIVE_INFINITY value in JavaScript_Basic knowledge

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

This is a special value that represents any value greater than Number.MAX_VALUE. This value is represented as "infinity". This value is similar to infinity in its mathematics. For example, anything multiplied by POSITIVE_INFINITY results in POSITIVE_INFINITY, and anything divided by POSITIVE_INFINITY results in zero.

Because POSITIVE_INFINITY is a constant, it is a read-only property.
Grammar

You can access properties using the following syntax:

var val = Number.POSITIVE_INFINITY;

Example:

Here is an example illustrating the usage of this attribute:

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

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