Math.LOG2E
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.LOG2E 靜態數據屬性表示 e 以 2 為底的對數值,約為 1.443。
嘗試一下
function getLog2e() {
return Math.LOG2E;
}
console.log(getLog2e());
// 預期輸出:1.4426950408889634
值
Math.LOG2E 的屬性特性 | |
|---|---|
| 可寫 | 否 |
| 可列舉 | 否 |
| 可配置 | 否 |
描述
由於 LOG2E 是 Math 的靜態屬性,因此你應始終以 Math.LOG2E 的方式使用,而非作為某個 Math 物件的屬性(Math 並不是建構子)。
範例
>使用 Math.LOG2E
以下函式返回 e 以 2 為底的對數值:
js
function getLog2e() {
return Math.LOG2E;
}
getLog2e(); // 1.4426950408889634
規範
| Specification |
|---|
| ECMAScript® 2026 Language Specification> # sec-math.log2e> |
瀏覽器相容性
Loading…