此頁面由社群從英文翻譯而來。了解更多並加入 MDN Web Docs 社群。

View in English Always switch to English

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 ⁨2015年7月⁩.

Math.E 靜態資料屬性代表歐拉數(Euler's number),即自然對數的底數 e ,其值約為 2.718。

嘗試一下

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

console.log(Math.E);
// 預期輸出:2.718281828459045

console.log((1 + 1 / 1000000) ** 1000000);
// 預期輸出:2.718280469 (approximately)

console.log(compoundOneYear(0.05, 100));
// 預期輸出:105.12710963760242

𝙼𝚊𝚝𝚑.𝙴=e2.718\mathtt{Math.E} = e \approx 2.718
Property attributes of Math.E 的屬性特性
可寫
可列舉
可配置

描述

由於 EMath 的靜態屬性,因此你必須使用 Math.E,而不是從你所建立的 Math 物件中存取該屬性(Math 並非建構子)。

範例

使用 Math.E

以下函式會回傳 e:

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

getNapier(); // 2.718281828459045

規範

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

瀏覽器相容性

參見