JavaScript

# What Does Math.LN10 Property Do in JavaScript

In JavaScript, the built-in “Math” object is beneficial to perform mathematical operations. It comes with numerous mathematical properties and methods such as “cos(x)”, “cosh(x)”, “exp(x)”, “LN(x)”, and many others. The “Math.LN(x)” is a static property that gives the natural log of a number. It allows the user to get the natural logarithm(ln) of a number(base “e”) like “Math.LN2”, “Math.LN10” and so on.

This guide explains the working of the “Math.LN10” property in JavaScript.

## What Does “Math.LN10” Property Do in JavaScript?

In the “Math.LN10” property, the “Math” object utilizes the “LN” (logarithmic) function that returns the number “10” natural logarithm. Its approximate value is equal to “2.302”.

Syntax

Math.LN10

In the above syntax:

• Math: Represents the built-in “Math” object.
• LN10: Specifies the logarithm of 10.

Let’s implement the above syntax to get the logarithm of 10.

Example: Applying the “Math.LN10” Property to Get Logarithm of 10
In this example, the “Math.LN10” property is used to find the base 10 natural logarithm.

HTML Code
First, overview of the HTML code:

<h2>Math.LN10 Property In JavaScript</h2>
<p>Math.LN10 returns the natural logarithm of 10:</p>
<p id="sample"></p>

In the above HTML code:

• <h2>” defines the first subheading.
• The first “<p>” HTML element creates a paragraph with the stated message.
• The second “<p>” tag creates an empty paragraph assigned an id “sample” to display the value of logarithm 10.

JavaScript Code
Next, move on to the JavaScript code:

<script>
document.getElementById("sample").innerHTML = Math.LN10;
</script>

In the JavaScript code, the “document.getElementById()” method fetches the empty paragraph via its id “sample” to display the logarithm of “10” with the help of the applied “Math.LN10” property.

Output In this output, it can be clearly seen that the logarithm of 10 is returned via the discussed property appropriately.

## Conclusion

JavaScript offers the built-in “Math.LN10” property to get the natural logarithm of 10 easily. It comes from the “Math” object properties that perform mathematical operations. However, the “Math.LN10” cannot be used as a function because it corresponds to a “static” JavaScript property i.e., its value is constant. This guide illustrated the objective and working of the “Math.LN10” property in JavaScript. 