Math.LN2

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.

Thuộc tính dữ liệu tĩnh Math.LN2 biểu thị logarithm tự nhiên của 2, xấp xỉ 0.693:

Try it

function getNatLog2() {
  return Math.LN2;
}

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

Giá trị

𝙼𝚊𝚝𝚑.𝙻𝙽𝟸=ln(2)0.693\mathtt{Math.LN2} = \ln(2) \approx 0.693
Property attributes of Math.LN2
Writableno
Enumerableno
Configurableno

Mô tả

LN2 là thuộc tính tĩnh của Math, bạn luôn sử dụng nó dưới dạng Math.LN2, thay vì là thuộc tính của một đối tượng Math bạn tạo ra (Math không phải là constructor).

Ví dụ

Sử dụng Math.LN2

Hàm sau trả về logarithm tự nhiên của 2:

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

getNatLog2(); // 0.6931471805599453

Đặc tả kỹ thuật

Specification
ECMAScript® 2027 Language Specification
# sec-math.ln2

Tương thích trình duyệt

Xem thêm