Math.sign
Returns the sign of a number: 1, -1 or 0.
Available since: ES2015
Syntax
Math.sign(x)Parameters
| Parameter | Type | Description |
|---|---|---|
| x | number | Any number. |
Return value
number1 for a positive number, -1 for a negative one, 0 for zero.
See also
- Math.abs — Returns the absolute value of a number — its value without the sign.
In the tutorial
- Numbers — Numbers in JavaScript — integers and fractions, rounding, the Math object, toFixed and the special values Infinity and NaN.