Home > Web Front-end > JS Tutorial > body text

Introduction to the use of POSITIVE_INFINITY value in JavaScript_Basic knowledge

WBOY
Release: 2016-05-16 15:56:28
Original
1551 people have browsed it

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;

Copy after login

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>

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!