このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docsコミュニティーについてもっと知り、仲間になるにはこちらから。
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 は静的プロパティで、オイラー定数である自然対数の底 (e)、約 2.718 を表します。
In this article
試してみましょう
function compoundOneYear(interestRate, currentVal) { return currentVal * Math.E ** interestRate;}console.log(Math.E);// 予想される結果: 2.718281828459045console.log((1 + 1 / 1000000) ** 1000000);// 予想される結果: 2.718280469 (approximately)console.log(compoundOneYear(0.05, 100));// 予想される結果: 105.12710963760242値
Math.E のプロパティ属性 | |
|---|---|
| 書込可能 | 不可 |
| 列挙可能 | 不可 |
| 設定可能 | 不可 |
解説
E はMath オブジェクトの静的プロパティなので、Math オブジェクトを生成してプロパティとして使用するのではなく、常にMath.E として使用するようにしてください(Math はコンストラクターではありません)。
例
>Math.E の使用
以下の関数は、e を返します。
js
function getNapier() { return Math.E;}getNapier(); // 2.718281828459045仕様書
| Specification |
|---|
| ECMAScript® 2026 Language Specification> # sec-math.e> |