1const positive = 5;
2const negative = -5;
3const zero = 0;
4
5Math.sign(positive); // 1
6Math.sign(negative); // -1
7Math.sign(zero); // 0
1(number < 0)
2
3"-0" < 0 is false, which is consistent with the fact that -0 < 0 is also false (see: signed zero).
4"-Infinity" < 0 is true (infinity is acknowledged)
5"-1e0" < 0 is true (scientific notation literals are accepted)
6"-0x1" < 0 is true (hexadecimal literals are accepted)
7" -1 " < 0 is true (some forms of whitespaces are allowed)
8
9
1Math.sign() has 5 possible return values:
21 // positive number
3-1 // negative number
40 // positive zero
5-0 // negative zero
6NaN // not a number