JavaScript Math.sign()
JavaScript Math.sign()
The Math.sign() method is used to return whether a number is negative, positive, or zero. It will return 1 if the number is positive, it will return -1 if the number is negative and it will return 0 for zero.
Syntax:-
Its syntax is:- Math.sign(x)
Return:-
Its return is:- a sign of either 1, -1, or 0 depending on the argument
Further Explanation:-
Parameter | Description |
---|---|
x | Required. The number. |