JavaScript Math LN10
Syntax & Examples
Math.LN10 static-property
The Math.LN10 property represents the natural logarithm of 10, which is approximately equal to 2.303.
Syntax of Math.LN10
The syntax of Math.LN10 static-property is:
Math.LN10
This LN10 static-property of Math natural logarithm of 10; approximately 2.303.
✐ Examples
1 Using Math.LN10 to calculate logarithm values
In JavaScript, we can use the Math.LN10
property to assist in logarithm calculations.
For example,
- We create a variable
logValue
and set it toMath.LN10
. - We log
logValue
to the console using theconsole.log()
method.
JavaScript Program
const logValue = Math.LN10;
console.log(logValue);
Output
2.302585092994046
2 Using Math.LN10 in a logarithmic expression
In JavaScript, we can use the Math.LN10
property in logarithmic expressions.
For example,
- We create a variable
x
and set it to 10. - We calculate the natural logarithm of
x
divided byMath.LN10
using theMath.log()
method. - The result is stored in the variable
result
. - We log
result
to the console using theconsole.log()
method.
JavaScript Program
const x = 10;
const result = Math.log(x) / Math.LN10;
console.log(result);
Output
1
3 Using Math.LN10 in a mathematical formula
In JavaScript, we can use the Math.LN10
property in various mathematical formulas.
For example,
- We create variables
a
andb
representing two numbers. - We calculate the natural logarithm of the product of
a
andb
using the formulaMath.log(a * b) / Math.LN10
. - The result is stored in the variable
logResult
. - We log
logResult
to the console using theconsole.log()
method.
JavaScript Program
const a = 2;
const b = 5;
const logResult = Math.log(a * b) / Math.LN10;
console.log(logResult);
Output
1
Summary
In this JavaScript tutorial, we learned about LN10 static-property of Math: the syntax and few working examples with output and detailed explanation for each example.