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.LN10This 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
logValueand set it toMath.LN10. - We log
logValueto 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
xand set it to 10. - We calculate the natural logarithm of
xdivided byMath.LN10using theMath.log()method. - The result is stored in the variable
result. - We log
resultto 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
aandbrepresenting two numbers. - We calculate the natural logarithm of the product of
aandbusing the formulaMath.log(a * b) / Math.LN10. - The result is stored in the variable
logResult. - We log
logResultto 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.