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

𝙼𝚊𝚝𝚑.𝙴=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® 2025 Language Specification
# sec-math.e

瀏覽器相容性

BCD tables only load in the browser

參見