Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / JavaScript

Number.POSITIVE_INFINITY: positive infinity

Number.POSITIVE_INFINITY is the Number value +∞, equal to global Infinity and greater than every finite number.

Version: ECMAScript 1 onward; example target: Node.js 24.22.2

Syntax

Number.POSITIVE_INFINITY

Number.POSITIVE_INFINITY stores positive infinity in the Number type. It equals global Infinity; it can also arise from overflow such as Number.MAX_VALUE * 2, or from dividing a positive number by +0. It is not a missing-value marker: test value === Infinity or Number.isFinite(value) according to the contract.

It compares greater than every finite number, but comparisons with NaN are false. Arithmetic follows IEEE 754 rules: Infinity - Infinity and 0 * Infinity produce NaN, 1 / Infinity produces +0, and operations with a negative sign can produce -Infinity. It is not a safe sentinel when later arithmetic can turn it into NaN.

The property has existed since ECMAScript 1 and is non-writable, non-enumerable, and non-configurable. Assigning another value is ignored in non-strict code and throws TypeError in strict mode. The constant is neither a function nor a constructor; before serialization, remember that JSON converts infinities to null.

Examples

const d = Object.getOwnPropertyDescriptor(Number, "POSITIVE_INFINITY");
console.log(Number.POSITIVE_INFINITY === Infinity, d.writable, d.enumerable, d.configurable);
console.log(Number.MAX_VALUE * 2, 1 / Number.POSITIVE_INFINITY);
console.log(Number.POSITIVE_INFINITY - Number.POSITIVE_INFINITY, Number.isFinite(Number.POSITIVE_INFINITY));
console.log(Number.POSITIVE_INFINITY > Number.MAX_VALUE, Number.POSITIVE_INFINITY < Number.NaN);

Result

true false false false
Infinity 0
NaN false
true false

The example checks the descriptor, overflow, division, and operations that produce NaN.

Sources