Javascript Math log10()

Introduction

The Math.log10() function returns the base 10 logarithm of a number.

Math.log10(x) // x is a number.

If the value of x is less than 0, the return value is always NaN.

This function is the equivalent of Math.log(x) / Math.log(10).

For log10(e) use the constant Math.LOG10E.

let a = Math.log10(2);      // 0.3010299956639812
console.log(a);/*from  w  ww .  j av a 2  s .  c  om*/
a = Math.log10(1);      // 0
console.log(a);
a = Math.log10(0);      // -Infinity
console.log(a);
a = Math.log10(-2);     // NaN
console.log(a);
a = Math.log10(100000); // 5
console.log(a);



PreviousNext

Related