JavaScript log10() method

Definition and usage

log10() The method returns the logarithm base 10 of the number.

Instance

Example 1

Return the logarithm base 10 of the number "2":

Math.log10(2);

Try it yourself

Example 2

Use the log10() method for different numbers:

var a = Math.log10(2.7183);
var b = Math.log10(2);
var c = Math.log10(1);
var d = Math.log10(0);
var e = Math.log10(-1);

Try it yourself

Syntax

Math.log10(x)

Parameter value

Parameter Description
x Required. Number.

Technical details

Return value:

A number, representing the logarithm of the number with base 10

  • If the number is negative, then return NaN
  • If the number is 0, then return -Infinity
JavaScript Version: ECMAScript 2015

Browser Support

Method Chrome Edge Firefox Safari Opera
log10() 38.0 12.0 25.0 8.0 25.0

Related Pages

Tutorial:JavaScript Math