Math.E

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.E biểu thị số Euler, cơ số của logarithm tự nhiên, e, xấp xỉ 2.718.

Try it

function compoundOneYear(interestRate, currentVal) {
  return currentVal * Math.E ** interestRate;
}

console.log(Math.E);
// Expected output: 2.718281828459045

console.log((1 + 1 / 1000000) ** 1000000);
// Expected output: 2.718280469 (approximately)

console.log(compoundOneYear(0.05, 100));
// Expected output: 105.12710963760242

Giá trị

𝙼𝚊𝚝𝚑.𝙴=e2.718\mathtt{Math.E} = e \approx 2.718
Property attributes of Math.E
Writableno
Enumerableno
Configurableno

Mô tả

E là thuộc tính tĩnh của Math, bạn luôn sử dụng nó dưới dạng Math.E, 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.E

Hàm sau trả về giá trị e:

js
function getNapier() {
  return Math.E;
}

getNapier(); // 2.718281828459045

Đặc tả kỹ thuật

Thông số kỹ thuật
ECMAScript® 2027 Language Specification
# sec-math.e

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

Xem thêm