constants
Math.E
Euler's number, the base of the natural logarithm, approximately 2.718281828459045. A read-only numeric property.
Math.E Parameters & edge cases
| Case | Behavior |
|---|---|
| precision | Double-precision approximation of e — not exact |
| relation to exp | Math.E === Math.exp(1) (up to floating-point equality) |
| relation to log | Math.log(Math.E) === 1 |
Examples
console.log(Math.E); // 2.718281828459045 The stored value.
console.log(Math.log(Math.E)); // 1 ln(e) = 1 by definition.
console.log(Math.exp(1) === Math.E); // true exp(1) matches Math.E exactly.
console.log(Math.pow(Math.E, 2)); // 7.3890560989306495 e² — note tiny rounding vs Math.exp(2) which returns 7.38905609893065.
Gotcha
Math.pow(Math.E, x) is slightly less accurate than Math.exp(x) because Math.E is rounded once before the power. Prefer Math.exp for e^x calculations.
Related
Math.PI
The ratio of a circle's circumference to its diameter, approximately 3.141592653589793. A read-only numeric property, not a function.
Math.exp
Returns e^x, where e is Euler's number (~2.71828). The inverse of Math.log (the natural logarithm).
Math.log
Returns the natural logarithm (base e, or ln) of a number. Inverse of Math.exp.