math-sign-x
Shim for Math.sign.
math-sign-x.sign2016
⇒ number
This method returns the sign of a number, indicating whether the number is positive,
negative or zero. (ES2016)
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 {sign2016} from 'math-sign-x';
console.log(sign2016(3));
console.log(sign2016(-3));
console.log(sign2016('-3'));
console.log(sign2016(0));
console.log(sign2016(-0));
console.log(sign2016(NaN));
console.log(sign2016('foo'));
console.log(sign2016());
math-sign-x
⇒ number
This method returns the sign of a number, indicating whether the number is positive,
negative or zero. (ES2018)
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));
console.log(mathSign(-3));
console.log(mathSign('-3'));
console.log(mathSign(0));
console.log(mathSign(-0));
console.log(mathSign(NaN));
console.log(mathSign('foo'));
console.log(mathSign());