Math.LN2

Math.LN2 静态数据属性表示 2 的自然对数,大约为 0.693:

¥The Math.LN2 static data property represents the natural logarithm of 2, approximately 0.693:

Try it

¥Value

𝙼𝚊𝚝𝚑.𝙻𝙽𝟸 = ln ( 2 ) 0.693 \mathtt{\mi{Math.LN2}} = \ln(2) \approx 0.693

Property attributes of Math.LN2
Writable no
Enumerable no
Configurable no

描述

¥Description

因为 LN2Math 的静态属性,所以你始终将其用作 Math.LN2,而不是用作你创建的 Math 对象的属性(Math 不是构造函数)。

¥Because LN2 is a static property of Math, you always use it as Math.LN2, rather than as a property of a Math object you created (Math is not a constructor).

示例

¥Examples

使用 Math.LN2

¥Using Math.LN2

以下函数返回 2 的自然对数:

¥The following function returns the natural log of 2:

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

getNatLog2(); // 0.6931471805599453

规范

Specification
ECMAScript Language Specification
# sec-math.ln2

¥Specifications

浏览器兼容性

BCD tables only load in the browser

¥Browser compatibility

也可以看看