math-sign-x
v4.2.2
Published
Shim for Math.sign.
Downloads
35,382
Maintainers
Readme
math-sign-x
Shim for Math.sign.
module.exports(x)
⇒ * ⏏
math-sign-x
⇒ number
This method returns the sign of a number, indicating whether the number is positive, negative or zero. (ES2019)
Kind: static property of math-sign-x
Returns: number - A number representing the sign of the given argument. If the argument
is a positive number, negative number, positive zero or negative zero, the function will
return 1, -1, 0 or -0 respectively. Otherwise, NaN is returned.
| Param | Type | Description | | ----- | --------------- | ----------- | | x | * | A number. |
Example
import mathSign from 'math-sign-x';
console.log(mathSign(3)); // 1
console.log(mathSign(-3)); // -1
console.log(mathSign('-3')); // -1
console.log(mathSign(0)); // 0
console.log(mathSign(-0)); // -0
console.log(mathSign(NaN)); // NaN
console.log(mathSign('foo')); // NaN
console.log(mathSign()); // NaN