How to get Natural logarithm of 2 in JavaScript?

To get the natural logarithm of 2 in JavaScript, use the Math.LN2 property. This built-in constant returns the natural logarithm of 2, which is approximately 0.693.

Syntax

Math.LN2

Return Value

The Math.LN2 property returns a number representing the natural logarithm of 2, approximately 0.6931471805599453.

Example

Here's how to access the natural logarithm of 2:

<html>
    <head>
        <title>JavaScript Math LN2 Property</title>
    </head>
    <body>
        <script>
            var property_value = Math.LN2;
            document.write("Property Value is : " + property_value);
        </script>
    </body>
</html>

Output

Property Value is : 0.6931471805599453

Practical Usage

You can use Math.LN2 in mathematical calculations involving natural logarithms:

<html>
    <body>
        <script>
            console.log("Natural log of 2:", Math.LN2);
            console.log("Using in calculation:", Math.LN2 * 3);
            console.log("Comparison with Math.log(2):", Math.log(2));
        </script>
    </body>
</html>

Key Points

  • Math.LN2 is a constant property, not a method
  • It's equivalent to Math.log(2) but more efficient
  • Commonly used in exponential and logarithmic calculations

Conclusion

The Math.LN2 property provides a convenient way to access the natural logarithm of 2. Use this constant for mathematical calculations requiring this specific logarithmic value.

Updated on: 2026-03-15T23:18:59+05:30

572 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements