JavaScript Math.LN2 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.
| Usage | What it does |
|---|
Math.LN2 | Read the natural logarithm of 2. |
Built into JavaScript. Read Math.LN2 directly from the Math object — no parentheses and no import required.
Library declarations
Parameters
None. Math.LN2 is a constant (a fixed value), not a function. Do not add parentheses.
Return Value
| Return Value | Description |
|---|
| Number | About 0.6931471805599453. |
JavaScript Examples
Example 1 — Read the Value of Math.LN2
No parentheses are needed.
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
0.6931471805599453
0.6931
true
How It Works
- Plain property.
Math.LN2 is a value, not a function. - Short form.
toFixed(4) keeps 4 decimals. - Same as log(2).
Math.log(2) gives the same number. - 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.
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
How It Works
- Change of base.
Math.log(x) / Math.LN2 is the base-2 log of x. - 8 is 2 three times. 2 × 2 × 2 is 8, so the answer is
3. - 1024. 2 to the power of 10 is 1024, so the answer is
10. - 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).
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
How It Works
- Growth factor.
1 + rate is 1.07. - Formula.
Math.LN2 / Math.log(1.07) gives the years to double. - Result. About
10.24 years. - Whole years.
Math.ceil() rounds up to 11.
Compatibility
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 supportMath.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.
About the author
Developer, cloud engineer, and technical writer
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