Math.E

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

La propriété Math.E représente la base du logarithme naturel, e, et vaut environ 2.718.

Math.E=e2.718\mathtt{\mi{Math.E}} = e \approx 2.718

Exemple interactif

function compoundOneYear(interestRate, currentVal) {
  return currentVal * Math.E ** interestRate;
}

console.log(Math.E);
// Expected output: 2.718281828459045

console.log((1 + 1 / 1000000) ** 1000000);
// Expected output: 2.718280469 (approximately)

console.log(compoundOneYear(0.05, 100));
// Expected output: 105.12710963760242
Attributs de Math.E
ÉcrivableNon
ÉnumérableNon
ConfigurableNon

Description

E étant une propriété statique de Math, il doit toujours être utilisé avec la syntaxe Math.E, et non pas être appelé comme propriété d'un autre objet Math qui aurait été créé (Math n'est pas un constructeur).

Exemples

Utiliser Math.E

La fonction suivante renvoie la valeur de e :

js
function getNapier() {
  return Math.E;
}

getNapier(); // 2.718281828459045

Spécifications

Specification
ECMAScript® 2025 Language Specification
# sec-math.e

Compatibilité des navigateurs

BCD tables only load in the browser

Voir aussi