check if number is negative javascript
const positive = 5;
const negative = -5;
const zero = 0;
Math.sign(positive); // 1
Math.sign(negative); // -1
Math.sign(zero); // 0
check if number is negative javascript
const positive = 5;
const negative = -5;
const zero = 0;
Math.sign(positive); // 1
Math.sign(negative); // -1
Math.sign(zero); // 0
javascript check negative number
(number < 0)
"-0" < 0 is false, which is consistent with the fact that -0 < 0 is also false (see: signed zero).
"-Infinity" < 0 is true (infinity is acknowledged)
"-1e0" < 0 is true (scientific notation literals are accepted)
"-0x1" < 0 is true (hexadecimal literals are accepted)
" -1 " < 0 is true (some forms of whitespaces are allowed)
check if number is negative javascript
Math.sign() has 5 possible return values:
1 // positive number
-1 // negative number
0 // positive zero
-0 // negative zero
NaN // not a number
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us