Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / JavaScript

Number.NEGATIVE_INFINITY: negative infinity

Number.NEGATIVE_INFINITY is the Number value -Infinity, smaller than every finite number and identical to global -Infinity.

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

Syntax

Number.NEGATIVE_INFINITY

Number.NEGATIVE_INFINITY is the same value as -Infinity and the result of -1 / 0. It is less than every finite Number and less than Number.POSITIVE_INFINITY; it is not the most negative finite number, which is -Number.MAX_VALUE. Reading the property does not throw.

Infinity arithmetic needs care: Number.NEGATIVE_INFINITY + Infinity and Number.NEGATIVE_INFINITY * 0 produce NaN, while dividing a finite value by an infinity can produce signed zero. Number.isFinite rejects this value. JSON.stringify writes infinities in arrays and object properties as null, so it does not preserve the sentinel.

The property has existed since ECMAScript 1 and is non-writable, non-enumerable, and non-configurable. The example uses it as an initial sentinel while finding the maximum of negative numbers; an empty input must be handled separately because it leaves the sentinel. In strict code, assignment to the property can throw TypeError.

Examples

function maximum(values) {
  let result = Number.NEGATIVE_INFINITY;
  for (const value of values) {
    if (value > result) result = value;
  }
  return result;
}

console.log(maximum([-8, -3, -11]), maximum([]) === Number.NEGATIVE_INFINITY);
console.log(Number.NEGATIVE_INFINITY === -Infinity, Number.NEGATIVE_INFINITY === -1 / 0);
console.log(Number.isFinite(Number.NEGATIVE_INFINITY), JSON.stringify(Number.NEGATIVE_INFINITY));
const descriptor = Object.getOwnPropertyDescriptor(Number, "NEGATIVE_INFINITY");
console.log(descriptor.writable, descriptor.enumerable, descriptor.configurable);

Result

-3 true
true true
false null
false false false

Number.NEGATIVE_INFINITY → maximum sentinel, empty input, arithmetic, and JSON

Sources