Math.sign Function (JavaScript)

Returns the sign of a number, indicating whether the number is positive, negative, or 0.

Syntax

Math.sign(number)  

Remarks

The required number argument is a numeric expression for which the sign is needed.

The return value is one of the following:

  • NaN, if number is NaN.

  • -0, if number is -0.

  • +0, if number is +0.

  • -1, if number is negative and not -0.

  • +1, if number is positive and not +0.

Requirements

Supported in Microsoft Edge (Edge browser). Also supported in Store apps (Microsoft Edge on Windows 10). See Version Information.
Not supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards, Internet Explorer 10 standards, Internet Explorer 11 standards. Not supported in Windows 8.1.