Javascript Number log(n)

Description

Javascript Number log(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);
};



PreviousNext

Related