Math.LN10
Updated March 13, 2026 · Math
javascript math constants logarithm
Math.LN10 is a static property of the Math object that holds the natural logarithm of 10 — approximately 2.302585092994046. It is a read-only constant; you cannot change its value.
Syntax
Math.LN10
Value
Math.LN10; // 2.302585092994046
This is equivalent to Math.log(10), but using the constant avoids a function call and is guaranteed to be the same value across all JavaScript engines.
Examples
Accessing the constant
console.log(Math.LN10);
// 2.302585092994046
Converting natural log to log base 10
// log base 10 of x = ln(x) / ln(10)
function log10(x) {
return Math.log(x) / Math.LN10;
}
console.log(log10(100));
// 2
console.log(log10(1000));
// 3
console.log(log10(1));
// 0
Equivalent to Math.log(10)
Math.LN10 === Math.log(10);
// true (they hold the same value)
Converting between logarithm bases
// General base conversion: log_b(x) = ln(x) / ln(b)
function logBase(x, base) {
return Math.log(x) / Math.log(base);
}
// Same as log base 10:
logBase(1000, 10); // 3
// Using the constant directly for base 10:
function log10fast(x) {
return Math.log(x) / Math.LN10;
}
console.log(log10fast(10000));
// 4
Common Patterns
Normalising values on a log scale
const values = [1, 10, 100, 1000, 10000];
const logScaled = values.map(v => Math.log(v) / Math.LN10);
console.log(logScaled);
// [0, 1, 2, 3, 4]
Estimating number of digits
function numberOfDigits(n) {
if (n === 0) return 1;
return Math.floor(Math.log(Math.abs(n)) / Math.LN10) + 1;
}
console.log(numberOfDigits(9)); // 1
console.log(numberOfDigits(99)); // 2
console.log(numberOfDigits(12345)); // 5
Working with decibels
// Decibels: dB = 10 * log10(power ratio)
function toDecibels(powerRatio) {
return 10 * (Math.log(powerRatio) / Math.LN10);
}
console.log(toDecibels(100));
// 20
console.log(toDecibels(1000));
// 30
See Also
- Math.log() — returns the natural logarithm of a number
- Math.exp() — returns e raised to the power of a number
- Math.sqrt() — returns the square root of a number