Number.POSITIVE_INFINITY

A special numeric value representing infinity. This value is represented as the unquoted literal "Infinity".

Property of Number
Static, Read-only

Description

This value behaves slightly differently than mathematical infinity:

  • Any positive value, including POSITIVE_INFINITY, multiplied by POSITIVE_INFINITY is POSITIVE_INFINITY.
  • Any negative value, including NEGATIVE_INFINITY, multiplied by POSITIVE_INFINITY is NEGATIVE_INFINITY.
  • Zero multiplied by POSITIVE_INFINITY is NaN.
  • NaN multiplied by POSITIVE_INFINITY is NaN.
  • POSITIVE_INFINITY, divided by any negative value except NEGATIVE_INFINITY, is NEGATIVE_INFINITY.
  • POSITIVE_INFINITY, divided by any positive value except POSITIVE_INFINITY, is POSITIVE_INFINITY.
  • POSITIVE_INFINITY, divided by either NEGATIVE_INFINITY or POSITIVE_INFINITY, is NaN.
  • Any number divided by POSITIVE_INFINITY is Zero.

Because POSITIVE_INFINITY is a static property of Number, you always use it as Number.POSITIVE_INFINITY, rather than as a property of a Number object you created.

Examples

In the following example, the variable bigNumber is assigned a value that is larger than the maximum value. When the if statement executes, bigNumber has the value "Infinity", so the func1 function is called.
var bigNumber = Number.MAX_VALUE * 10;
if ( bigNumber == Number.POSITIVE_INFINITY )
func1();
else
func2();

See also

Infinity, isFinite


Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.