Get the sign of a number - Node.js Number

Node.js examples for Number:Algorithm

Description

Get the sign of a number

Demo Code


sign = function (x) {
    return typeof x === 'number' ? x ? x < 0 ? -1 : 1 : x === x ? 0 : NaN : NaN;
};

Related Tutorials