Nodejs Radian to Degree Convert toDegrees()

Here you can find the source of toDegrees()

Method Source Code

// Consider Number to radians and convert to degrees.
Number.prototype.toDegrees = function () {
    return this * (180 / Math.PI);
};

// Consider Number to degrees and convert to radians.
Number.prototype.toRadians = function () {
    return this * (Math.PI / 180);
};

// Modulo function which perform nicely in negative numbers.
Number.prototype.mod = function (n) {
    return ((this % n) + n) % n;
};

// Usage of Math.pow in prototype definition.
Number.prototype.pow = function (n) {
   return Math.pow(this, n);
};

// Take log_n of this number. If no arguments supplied, log_e(napier) is assumed.
Number.prototype.log = function (n) {
   if (typeof n === 'undefined') n = Math.E;
   if (n <= 0) return Number.NaN;
   return Math.log(this) / Math.log(n);
};

Related

  1. toDeg()
    Number.prototype.toDeg = function() {
      return this * 180 / Math.PI;
    Number.prototype.toRad = function() {
      return this * Math.PI / 180;
    
  2. toDeg()
    Number.prototype.toDeg = function() {
       return this * 180 / Math.PI;
    
  3. toDeg()
    const degsInRad = 180 / Math.PI,
          radsInDeg = Math.PI / 180,
          rad360 = Math.PI * 2;
    Number.prototype.toDeg = function() {
        let deg = (this * degsInRad) % 360;
        if (deg < 0) {
            if (deg / 360 < -1) {
                deg += Math.floor((-deg) / 360) * 360
            } else {
    ...
    
  4. toDeg()
    Number.prototype.toDeg = function() {
      return (this * 180) / Math.PI;
    };
    
  5. toDeg() // convert radians to degrees (signed)
    Number.prototype.toDeg = function() {  
      return this * 180 / Math.PI;
    
  6. toDegrees()
    Number.prototype.toDegrees = function() { 
        return this.valueOf() * (180 * Math.PI); 
    
  7. radToDeg()
    Number.prototype.radToDeg = function () {
      return this.valueOf() / Math.PI * 180;