JavaScript Math.LN2 Constant

Beginner
5 min read
Updated: Nov 2026
3 examples
Constant

Definition

Math.LN2 is a built-in constant that holds the natural logarithm of 2, about 0.6931471805599453. You read it as a property. You do not call it.

Read the value, use it in your math, and check the examples below for common patterns.

Syntax

Read the constant. Start with this line.

JavaScript
Math.LN2
UsageWhat it does
Math.LN2Read the natural logarithm of 2.

Built into JavaScript. Read Math.LN2 directly from the Math object — no parentheses and no import required.

Library declarations
JavaScript
Math.LN2

Parameters

None. Math.LN2 is a constant (a fixed value), not a function. Do not add parentheses.

Return Value

Return ValueDescription
NumberAbout 0.6931471805599453.

JavaScript Examples

Example 1 — Read the Value of Math.LN2

No parentheses are needed.

JavaScript
console.log(Math.LN2); // 0.6931471805599453
console.log(Math.LN2.toFixed(4)); // 0.6931
console.log(Math.log(2).toFixed(10) === Math.LN2.toFixed(10)); // true
Try It Yourself

How It Works

  1. Plain property. Math.LN2 is a value, not a function.
  2. Short form. toFixed(4) keeps 4 decimals.
  3. Same as log(2). Math.log(2) gives the same number.
  4. Why it exists. It saves you from calculating Math.log(2) again and again.

Example 2 — Log Base 2 with Math.LN2

Divide a natural log by Math.LN2 to get a base-2 log.

JavaScript
console.log((Math.log(8) / Math.LN2).toFixed(4)); // 3.0000
console.log((Math.log(1024) / Math.LN2).toFixed(4)); // 10.0000
console.log(Math.log2(8)); // 3
Try It Yourself

How It Works

  1. Change of base. Math.log(x) / Math.LN2 is the base-2 log of x.
  2. 8 is 2 three times. 2 × 2 × 2 is 8, so the answer is 3.
  3. 1024. 2 to the power of 10 is 1024, so the answer is 10.
  4. Shortcut. Math.log2(8) does this in one step.

Example 3 — How Long to Double?

At a growth rate of 7% per year, how many years to double? The formula is Math.LN2 / Math.log(1 + rate).

JavaScript
const rate = 0.07;
const years = Math.LN2 / Math.log(1 + rate);

console.log(years.toFixed(2)); // 10.24
console.log(Math.ceil(years)); // 11
Try It Yourself

How It Works

  1. Growth factor. 1 + rate is 1.07.
  2. Formula. Math.LN2 / Math.log(1.07) gives the years to double.
  3. Result. About 10.24 years.
  4. Whole years. Math.ceil() rounds up to 11.

Browser & Runtime Support

Math.LN2 is part of the first JavaScript standard (ES1) and is Baseline Widely available in every browser and in Node.js.

✓ Baseline · ES1

Math.LN2

A long-standing constant. It works in Chrome, Firefox, Safari, Edge, Internet Explorer and Node.js.

99% Modern browser support
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
Math.LN2 Excellent

Bottom line: Use Math.LN2 anywhere. It works in all browsers.

Frequently Asked Questions

It is the natural logarithm of 2, about 0.6931471805599453.
No. It is a number. Write Math.LN2 without parentheses.
Use Math.log2(x). You can also write Math.log(x) / Math.LN2.
Years to double = Math.LN2 / Math.log(1 + rate). For 7% growth that is about 10.24 years.
Yes. They have the same value. Math.LN2 is ready to read without calling a function.
All of them. It is part of the first JavaScript standard and works in every browser and in Node.js.

Next: LOG10E

Learn about base-10 log of e.

LOG10E tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

9 people found this page helpful