JavaScript Math.sign()
Description
The Math.sign()
method retuns whether a number is negative, positive or zero.
If the number is positive, this method returns 1.
If the number is negative, it returns -1.
If the number is zero, it returns 0.
Browser Support
Math.sign()
is an ECMAScript6 (ES6) feature.
ES6 (JavaScript 2015) is supported in all modern browsers since June 2017:
Chrome 51 | Edge 15 | Firefox 54 | Safari 10 | Opera 38 |
May 2016 | Apr 2017 | Jun 2017 | Sep 2016 | Jun 2016 |
Math.sign()
is not supported in Internet Explorer.
Syntax
Math.sign(x)
Parameters
Parameter | Description |
---|---|
x | Required. A number. |
Return Value
A Number, representing the sign of the specified number:
|