JS: Infinity

By Xah Lee. Date: . Last updated: .

What is Infinity

Infinity is the value of the property key "Infinity" of the Global Object.

Infinity is a literal value. For example, you can write let x = Infinity;

console.assert(globalThis["Infinity"] === Infinity);

Purpose of Infinity

Infinity is typically returned when divide by zero.

console.assert(1 / 0 === Infinity);

Type of Infinity

Type of Infinity is number.

console.assert(typeof Infinity === "number");

Infinity === Infinity return true.

console.assert(Infinity === Infinity);

Test Infinity

JavaScript. Special Literals