 # JavaScript Math log10()

In this tutorial, you will learn about the JavaScript Math.log10() method with the help of examples.

The `Math.log10()` method returns the base 10 logarithm of a number. It is equivalent to log10(x) in mathematics.

### Example

``````// calculate the base 10 log of 100
var value = Math.log10(100);

console.log(value);

// Output: 2``````

## log10() Syntax

The syntax of `log10()` is:

``Math.log10(x)``

Here, `log10()` is a static method. Hence, we need to access the method using the class name, `Math`.

## log10() Parameter

The `log10()` method takes in:

• x - a number

## log10() Return Values

The `log10()` method returns:

• the base 10 logarithm of the given number.
• `NaN` for negative numbers and non-numeric arguments.

## Example 1: JavaScript Math.log10()

``````// find the base 10 log value of 1
var value1 = Math.log10(1);

console.log(value1);

// find the base 10 log value of 10
var value2=Math.log10(10);

console.log(value2)``````

Output

```0
1```

In the above example,

• `Math.log10(1)` - computes the base 10 log value of 1
• `Math.log10(10)` - computes the base 10 log value of 10

## Example 2: log10() With 0

``````// find the base 10 log value of 0
var value = Math.log10(0);

console.log(value);

// Output: -Infinity``````

In the above example, we have used the `log10()` method to compute the base 10 log value of 0.

The output `-Infinity` indicates that the base 10 log value of 0 is negative infinity.

## Example 3: log10() With Negative Values

``````// find the base 10 log of negative values
var value = Math.log10(-1);

console.log(value);

// Output: NaN``````

In the above example, we have used the `log10()` method to compute the base 10 log value of a negative number.

The output `NaN` stands for Not a Number. We get this result because the base 10 log value of negative numbers is undefined.