JS Special Numbers
Syntax
JavaScript includes special numeric values such as Infinity, -Infinity, and NaN (Not-a-Number).
let positiveInfinity = Infinity; // Represents a value too large to representlet negativeInfinity = -Infinity; // Represents a value too small to representlet notANumber = NaN; // Represents an invalid number resultExample
console.log(1 / 0); // Outputs: Infinityconsole.log(-1 / 0); // Outputs: -Infinityconsole.log("text" * 3); // Outputs: NaNconsole.log(isNaN("text")); // true, checks if the value is NaN