JavaScript Math LOG2E
Syntax & Examples


Math.LOG2E static-property

The Math.LOG2E property represents the base-2 logarithm of Euler's number (E), which is approximately equal to 1.443.


Syntax of Math.LOG2E

The syntax of Math.LOG2E static-property is:

Math.LOG2E

This LOG2E static-property of Math base-2 logarithm of E; approximately 1.443.



✐ Examples

1 Using Math.LOG2E to calculate logarithmic values

In JavaScript, we can use the Math.LOG2E property to assist in base-2 logarithm calculations.

For example,

  1. We create a variable logValue and set it to Math.LOG2E.
  2. We log logValue to the console using the console.log() method.

JavaScript Program

const logValue = Math.LOG2E;
console.log(logValue);

Output

1.4426950408889634

2 Using Math.LOG2E in a logarithmic expression

In JavaScript, we can use the Math.LOG2E property in logarithmic expressions.

For example,

  1. We create a variable x and set it to Math.E.
  2. We calculate the base-2 logarithm of x using Math.LOG2E.
  3. The result is stored in the variable logResult.
  4. We log logResult to the console using the console.log() method.

JavaScript Program

const x = Math.E;
const logResult = Math.LOG2E;
console.log(logResult);

Output

1.4426950408889634

3 Using Math.LOG2E in a mathematical formula

In JavaScript, we can use the Math.LOG2E property in various mathematical formulas involving logarithms.

For example,

  1. We create variables a and b representing two numbers.
  2. We calculate the base-2 logarithm of the quotient of a and b using the formula Math.log2(a / b).
  3. The result is stored in the variable logQuotient.
  4. We log logQuotient to the console using the console.log() method.

JavaScript Program

const a = 8;
const b = 2;
const logQuotient = Math.log2(a / b);
console.log(logQuotient);

Output

2

Summary

In this JavaScript tutorial, we learned about LOG2E static-property of Math: the syntax and few working examples with output and detailed explanation for each example.