Math.LN2

Baseline 已廣泛支援

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

Math.LN2 靜態資料屬性表示 2 的自然對數,約等於 0.693。

試一試

function getNatLog2() {
  return Math.LN2;
}

console.log(getNatLog2());
// Expected output: 0.6931471805599453

𝙼𝚊𝚝𝚑.𝙻𝙽𝟸=ln(2)0.693\mathtt{Math.LN2} = \ln(2) \approx 0.693
Math.LN2 的屬性特性
可寫
可列舉
可配置

描述

由於 LN2Math 的靜態屬性,所以你總是透過 Math.LN2 來使用它,而不是透過你建立的 Math 物件屬性來使用(Math 不是一個建構函式)。

示例

使用 Math.LN2

以下函式返回 2 的自然對數

js
function getNatLog2() {
  return Math.LN2;
}

getNatLog2(); // 0.6931471805599453

規範

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

瀏覽器相容性

另見