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.
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
值
Property attributes of Math.E 的屬性特性 | |
---|---|
可寫 | 否 |
可列舉 | 否 |
可配置 | 否 |
描述
由於 E
是 Math
的靜態屬性,因此你必須使用 Math.E
,而不是從你所建立的 Math
物件中存取該屬性(Math
並非建構子)。
範例
使用 Math.E
以下函式會回傳 e:
js
function getNapier() {
return Math.E;
}
getNapier(); // 2.718281828459045
規範
Specification |
---|
ECMAScript® 2025 Language Specification # sec-math.e |
瀏覽器相容性
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
E |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.