Math.LN2
Math.LN2 靜態資料屬性表示 2 的自然對數,約等於 0.693。
試一試
function getNatLog2() {
return Math.LN2;
}
console.log(getNatLog2());
// Expected output: 0.6931471805599453
值
Math.LN2 的屬性特性 | |
|---|---|
| 可寫 | 否 |
| 可列舉 | 否 |
| 可配置 | 否 |
描述
由於 LN2 是 Math 的靜態屬性,所以你總是透過 Math.LN2 來使用它,而不是透過你建立的 Math 物件屬性來使用(Math 不是一個建構函式)。
示例
使用 Math.LN2
以下函式返回 2 的自然對數
js
function getNatLog2() {
return Math.LN2;
}
getNatLog2(); // 0.6931471805599453
規範
| 規範 |
|---|
| ECMAScript® 2026 語言規範 # sec-math.ln2 |
瀏覽器相容性
載入中…