Math.log1p()
函数返回一个数字加1后的自然对数 (底为 E
), 既log(x+1)
.
Math.log1p(x)
x
如果参数的值小于 -1
, 则返回 NaN.
函数 y = log(x+1) 的图形是这样的:
示例
Math.log1p(Math.E-1) // 1
Math.log1p(0) // 0
Math.log1p("0") // 0
Math.log1p(-1) // -Infinity
Math.log1p(-2) // NaN
Math.log1p("foo") // NaN
Specification | Status | Comment |
---|---|---|
ECMAScript 2015 (6th Edition, ECMA-262) Math.log1p |
Standard | Initial definition. |
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | 未实现 | 25 (25) | 未实现 | 未实现 | 未实现 |
Feature | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Basic support | 未实现 | 未实现 | 25.0 (25) | 未实现 | 未实现 | 未实现 |
Math
对象.