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.
Math.sign()
is an ECMAScript6 (ES6) feature.
ES6 (JavaScript 2015) is supported in all modern browsers:
Chrome | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes |
Math.sign()
is not supported in Internet Explorer 11 (or earlier).
Math.sign(
x)
Parameter | Description |
---|---|
x | Required. A number. |
A Number, representing the sign of the specified number:
|
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!