isNegative
The isNegative function checks if a number is negative.
Syntax
typescript
isNegative(value)Parameters
| Name | Type | Description |
|---|---|---|
value | number | Number to be checked. |
Return Value
| Type | Description |
|---|---|
boolean | true if the number is negative, else false. |
Examples
typescript
isNegative(-5); // true
isNegative(0); // false
isNegative(10); // falseNotes
- Throws a
TypeErrorif the value is not a number. - Useful for mathematical and logical validations.
