--- title: Math.expm1() slug: Web/JavaScript/Reference/Global_Objects/Math/expm1 translation_of: Web/JavaScript/Reference/Global_Objects/Math/expm1 ---
Math.expm1()
函数返回 Ex - 1
, 其中 x
是该函数的参数, E
是自然对数的底数 2.718281828459045.
Math.expm1(x)
x
参数
x
会被自动类型转换成 number
类型.
expm1 是 "exponent minus 1" 的缩写.
Math.expm1(1) // 1.7182818284590453 Math.expm1(-38) // -1 Math.expm1("-38") // -1 Math.expm1("foo") // NaN
因为我们已经有了 Math.exp
函数, 所以很容易 polyfill.
Math.expm1 = Math.expm1 || function (x) { return Math.exp(x) - 1 }
Specification | Status | Comment |
---|---|---|
{{SpecName('ES6', '#sec-math.expm1', 'Math.expm1')}} | {{Spec2('ES6')}} | Initial definition. |
{{ CompatibilityTable() }}
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | {{CompatNo}} | {{CompatGeckoDesktop("25")}} | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} |
Feature | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Basic support | {{CompatNo}} | {{CompatNo}} | {{CompatGeckoMobile("25")}} | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} |