試一試
function getLog2e() {
return Math.LOG2E;
}
console.log(getLog2e());
// Expected output: 1.4426950408889634
值
Math.LOG2E 的屬性特性 | |
|---|---|
| 可寫 | 否 |
| 可列舉 | 否 |
| 可配置 | 否 |
描述
因為 LOG2E 是 Math 的靜態屬性,所以你總是透過 Math.LOG2E 來使用它,而不是作為你建立的 Math 物件(Math 不是建構函式)的屬性。
示例
使用 Math.LOG2E
下面的函式返回 e 的以 2 為底的對數
js
function getLog2e() {
return Math.LOG2E;
}
getLog2e(); // 1.4426950408889634
規範
| 規範 |
|---|
| ECMAScript® 2026 語言規範 # sec-math.log2e |
瀏覽器相容性
載入中…