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 July 2015.

Math.LOG2E 靜態數據屬性表示 e 以 2 為底的對數值,約為 1.443。

嘗試一下

function getLog2e() {
  return Math.LOG2E;
}

console.log(getLog2e());
// Expected output: 1.4426950408889634

𝙼𝚊𝚝𝚑.𝙻𝙾𝙶𝟸𝙴=log2(e)1.443\mathtt{Math.LOG2E} = \log_2(\mathrm{e}) \approx 1.443
Property attributes of Math.LOG2E 的屬性特性
可寫
可列舉
可配置

描述

由於 LOG2EMath 的靜態屬性,因此你應始終以 Math.LOG2E 的方式使用,而非作為某個 Math 物件的屬性(Math 並不是建構子)。

範例

使用 Math.LOG2E

以下函式返回 e 以 2 為底的對數值:

js
function getLog2e() {
  return Math.LOG2E;
}

getLog2e(); // 1.4426950408889634

規範

Specification
ECMAScript® 2025 Language Specification
# sec-math.log2e

瀏覽器相容性

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
LOG2E

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

參見