JavaScript Math.LN10 Property

Shubham Vora Jan 30, 2023
  1. Syntax of JavaScript Math.LN10 Property
  2. Example 1: Use Math.LN10 Property to Get the Natural Logarithm of 10
  3. Example 2: Pass the Math.LN10 Property to Function Arguments
  4. Example 3: Perform Various Arithmetic Operations With the Value of Math.LN10 Property
JavaScript Math.LN10 Property

In JavaScript, Math.LN10 property is used to get the value of the natural logarithm of 10. The natural logarithm of 10 means log of 10 on Base E, and its value is constant, which is approximately 2.302.

As we know, LN10 is a static property of the Math library. We always have to call the LN10 with a Math library.

Syntax of JavaScript Math.LN10 Property

Math.LN10;

Parameters

The Math.LN10 doesn’t take any parameter.

Return

The Math.LN10 property always returns the natural logarithm of 10, which is approximately 2.302.

Example 1: Use Math.LN10 Property to Get the Natural Logarithm of 10

Whenever users need to get the natural logarithm of 10, which means logE(10), they should use the Math.LN10 method.

In the example below, we have used the Math.LN10 method, and users can see its output, which is approximately 2.302 equals the natural logarithm of 10.

let value = Math.LN10;
console.log(value);

Output:

2.302585092994046

Example 2: Pass the Math.LN10 Property to Function Arguments

As the Math.LN10 property always returns the constant value, we can also pass it as a function argument and use it inside the function to perform some operation.

In the example below, we have created the function named func and passed Math.LN10 as its argument while invoking it. Also, we are performing the addition operation of parameters inside the func.

function func(param1, param2){
    console.log(param1+param2)
}
func(10,Math.LN10);

Output:

12.302585092994047

Example 3: Perform Various Arithmetic Operations With the Value of Math.LN10 Property

Users can perform various arithmetic operations with the value of the Math.LN10 property which is approximately 2.302. In this example, we have performed addition, subtraction, division, and multiplication operations with the Math.LN10 value.

let value1 = 20 + Math.LN10;
let value2 =  3*Math.LN10;
console.log(value1);
console.log(value2);
console.log(5.2 - Math.LN10);
console.log(50/Math.LN10);

Output:

22.302585092994047
6.907755278982138
2.8974149070059543
21.71472409516259

Most modern browsers support the Math.LN10 property, and users can use it to find the natural logarithm of 10 with a single line of code.

Author: Shubham Vora
Shubham Vora avatar Shubham Vora avatar

Shubham is a software developer interested in learning and writing about various technologies. He loves to help people by sharing vast knowledge about modern technologies via different platforms such as the DelftStack.com website.

LinkedIn GitHub

Related Article - JavaScript Math