Here you can find the source of sign()
Number.prototype.sign = function() { if(this > 0) { return 1;/*from w w w . j av a2 s . c o m*/ } else if (this < 0) { return -1; } else { return 0; } }
Math.sign = function(x) { if (x > 0) { return 1 } else if (x < 0) { return -1 } else { return 0
Math.prototype.sign = function(d) { return d<0 ? -1 : 1; };
Math.sign = function(x) { x = +x; if (x === 0 || isNaN(x)) return x; return x > 0 ? 1 : -1;
Math.sign = Math.sign || function (x) { return x === 0 ? 0 : x / Math.abs(x); };
Math.sign = function(x) { if (x > 0) { return 1 } else if (x < 0) { return -1 } else { return 0
Number.prototype.sign = function() { return (this>0) - (this<0); };
'use strict'; Number.prototype.signed = function () { return this & 0x80 ? -((0xff & ~this) + 1) : this; };