Home >Web Front-end >JS Tutorial >Introduction to the use of POSITIVE_INFINITY value in JavaScript_Basic knowledge
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