Skip to content

isInfinity ​

The isInfinity function checks if a value is positive or negative infinity.

Syntax ​

typescript
isInfinity(value)

Parameters ​

NameTypeDescription
valuenumberValue to be checked.

Return Value ​

TypeDescription
booleantrue if the value is Infinity or -Infinity, else false.

Examples ​

typescript
isInfinity(Infinity);  // true
isInfinity(-Infinity); // true
isInfinity(10);        // false

Notes ​

  • Throws a TypeError if the value is not a number.
  • Useful for mathematical validations and handling extreme limits.

References ​

Released under the MIT License.