JavaScript Math sign() Method

The Math.sign() method retuns whether a number is negative, positive or zero

Browser Support

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).

Syntax

Math.sign(x)

Parameters

Parameter Description
x Required. A number.

Return Value

A Number, representing the sign of the specified number:
  • If the number is positive, it returns 1
  • If the number is negative, it returns -1
  • If the number is positive zero, it returns 0
  • If the number is negative zero, it returns -0
  • If the number is not a number, it returns NaN