JavaScript Math.LN10 Constant

Definition
Math.LN10 is a built-in constant that holds the natural logarithm of 10, about 2.302585092994046. 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.LN10 | Read the natural logarithm of 10. |
Built into JavaScript. Read Math.LN10 directly from the Math object — no parentheses and no import required.
Library declarations
Parameters
None. Math.LN10 is a constant (a fixed value), not a function. Do not add parentheses.
Return Value
| Return Value | Description |
|---|
| Number | About 2.302585092994046. |
JavaScript Examples
Example 1 — Read the Value of Math.LN10
No parentheses are needed.
console.log(Math.LN10); // 2.302585092994046
console.log(Math.LN10.toFixed(4)); // 2.3026
console.log(Math.log(10).toFixed(10) === Math.LN10.toFixed(10)); // true
2.302585092994046
2.3026
true
How It Works
- Plain property.
Math.LN10 is a value, not a function. - Short form.
toFixed(4) keeps 4 decimals. - Same as log(10).
Math.log(10) gives the same number. - Why it exists. It saves you from calculating
Math.log(10) again and again.
Example 2 — Log Base 10 the Old Way
Divide a natural log by Math.LN10 to get a base-10 log. Compare it with Math.log10().
console.log(Math.log(1000) / Math.LN10); // 2.9999999999999996
console.log((Math.log(1000) / Math.LN10).toFixed(4)); // 3.0000
console.log(Math.log10(1000)); // 3
2.9999999999999996
3.0000
3
How It Works
- Change of base.
Math.log(x) / Math.LN10 is the base-10 log of x. - Tiny error. The raw answer is
2.9999999999999996, not exactly 3. - Round it.
toFixed(4) shows "3.0000". - Better choice.
Math.log10(1000) is exactly 3.
Example 3 — Count the Digits in a Number
The number of digits is the base-10 log, rounded down, plus 1.
function digitCount(n) {
return Math.floor(Math.log(n) / Math.LN10) + 1;
}
console.log(digitCount(5)); // 1
console.log(digitCount(42)); // 2
console.log(digitCount(12345)); // 5
How It Works
- Log.
Math.log(n) / Math.LN10 is the base-10 log of n. - Round down.
Math.floor() removes the decimals. - Add one. A number like 42 has log 1.6, floor 1, plus 1 is
2 digits. - Careful. Exact powers like 1000 can be off by one. Use
Math.log10() for those.
Compatibility
Browser & Runtime Support
Math.LN10 is part of the first JavaScript standard (ES1) and is Baseline Widely available in every browser and in Node.js.
✓ Baseline · ES1
Math.LN10
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.LN10 Excellent
Bottom line: Use Math.LN10 anywhere. It works in all browsers.
Frequently Asked Questions
It is the natural logarithm of 10, about 2.302585092994046.
No. It is a number. Write Math.LN10 without parentheses.
Use Math.log10(x). It is more accurate than Math.log(x) / Math.LN10.
Computers store decimals with tiny rounding errors, so the result is 2.9999999999999996. Math.log10(1000) returns exactly 3.
Yes. They have the same value. Math.LN10 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