Math.LN2
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.LN2 は静的データプロパティで、 2 の自然対数、およそ 0.693 を表します。
試してみましょう
function getNatLog2() { return Math.LN2; } console.log(getNatLog2()); // 予想される結果: 0.6931471805599453 値
Math.LN2 のプロパティ属性 | |
|---|---|
| 書込可能 | 不可 |
| 列挙可能 | 不可 |
| 設定可能 | 不可 |
解説
LN2 は Math オブジェクトの静的プロパティなので、 Math オブジェクトを生成してプロパティとして使用するのではなく、常に Math.LN2 として使用するようにしてください (Math はコンストラクターではありません)。
例
>Math.LN2 の使用
以下の関数は、2 の自然対数を返します。
js
function getNatLog2() { return Math.LN2; } getNatLog2(); // 0.6931471805599453 仕様書
| Specification |
|---|
| ECMAScript® 2026 Language Specification> # sec-math.ln2> |