Skip to content

Xotic750/math-sign-x

Repository files navigation

Travis status Dependency status devDependency status npm version jsDelivr hits bettercodehub score Coverage Status

math-sign-x

Shim for Math.sign.

module.exports(x)*

math-sign-xnumber

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