Curriculum
Course: JavaScript Basic
Login

Curriculum

JavaScript Basic

JSHome

0/216
Text lesson

Infinity

Infinity (or -Infinity) is the value that JavaScript will return if a calculation yields a number beyond the maximum limit.

Example

let myNumber = 2;
// Execute until Infinity
while (myNumber != Infinity) {
  myNumber = myNumber * myNumber;
}

Division by 0 (zero) likewise results in Infinity.

Example

let x =  2 / 0;
let y = –2 / 0;

Infinity is categorized as a number; invoking typeof Infinity will yield “number“.

Example

typeof Infinity;