Math.sign()
ℹ️ Use to detect whether a number is positive, negative, or zero.
Description
Math.sign()
function returns the sign of the value, indicating whether a number is positive, negative, or zero. It the following values:
1
- for positive numbers-1
- for negative numbers0
- for positive zero-0
- for negative zeroNaN
- in all other cases
The argument passed to this function will be converted to number
type implicitly.
Example
Last updated
Was this helpful?