isInfinity
The isInfinity function checks if a value is positive or negative infinity.
Syntax
typescript
isInfinity(value)Parameters
| Name | Type | Description |
|---|---|---|
value | number | Value to be checked. |
Return Value
| Type | Description |
|---|---|
boolean | true if the value is Infinity or -Infinity, else false. |
Examples
typescript
isInfinity(Infinity); // true
isInfinity(-Infinity); // true
isInfinity(10); // falseNotes
- Throws a
TypeErrorif the value is not a number. - Useful for mathematical validations and handling extreme limits.
