Javascript Number sign()

Description

Javascript Number sign()


Number.prototype.sign = function () {
  return this < 0 ? -1 : 1;
}

Javascript Number sign()

Number.prototype.sign = function() {
  if(this > 0) {
    return 1;// w w  w  . j av a  2  s . c om
  } else if (this < 0) {
    return -1;
  } else {
    return 0;
  }
}

Javascript Number sign()

Number.prototype.sign = function() {
    return (this>0) - (this<0);
};



PreviousNext

Related