POSITIVE_INFINITY (JavaScript)

Positive infinity.

Defined in

Number (Standard - JavaScript)

Syntax

Number.POSITIVE_INFINITY

Usage

POSITIVE_INFINITY is a constant and has the same value whether called statically as shown in the syntax or from an object.

A positive number greater than MAX_VALUE has the value POSITIVE_INFINITY.

POSITIVE_INFINITY has the string representation ? (question mark) or +? (plus sign, question mark).

Division by zero results in infinity.

Examples

The following example prints positive infinity then shows that positive infinity is the result of a very large number or division by zero.
function p(stuff) {
 	print("<<<" + stuff + ">>>");
}

try {
	p(Number.POSITIVE_INFINITY.toString()); // prints <<<?>>>
	p(Number.POSITIVE_INFINITY.valueOf()); // prints <<<Infinity>>>
	var n = new Number(1.7976931348623157E309);
	if (n == Number.POSITIVE_INFINITY) {
		p(n + " = Number.POSITIVE_INFINITY");
		// prints <<<Infinity = Number.POSITIVE_INFINITY>>>
	}
	if ((5/0) == Number.POSITIVE_INFINITY) {
		p("division by 0 = Number.POSITIVE_INFINITY");
		//prints <<<division by 0 = Number.POSITIVE_INFINITY>>>
	}
	
} catch(e) {
	p("Error = " + e);
}