Math.E

Baseline 已廣泛支援

此特性已相當成熟,可在許多裝置和瀏覽器版本上使用。自 ⁨2015 年 7 月⁩以來,各瀏覽器均已提供此特性。

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

試一試

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

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

描述

因為 EMath 的靜態屬性,所以你總是透過 Math.E 來使用它,而不是透過你自己建立的 Math 物件屬性來使用(Math 不是一個建構函式)。

示例

使用 Math.E

下面的函式返回 e

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

getNapier(); // 2.718281828459045

規範

規範
ECMAScript® 2026 語言規範
# sec-math.e

瀏覽器相容性

另見