Skip to content

isNegative ​

The isNegative function checks if a number is negative.

Syntax ​

typescript
isNegative(value)

Parameters ​

NameTypeDescription
valuenumberNumber to be checked.

Return Value ​

TypeDescription
booleantrue if the number is negative, else false.

Examples ​

typescript
isNegative(-5); // true
isNegative(0);  // false
isNegative(10); // false

Notes ​

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

References ​

Released under the MIT License.