JavaScript exp() 方法
定义和用法
exp() 方法可返回 e 的 x 次幂的值。
语法
Math.exp(x)
| 参数 | 描述 |
|---|---|
| x | 必需。任意数值或表达式。被用作指数。 |
返回值
返回 e 的 x 次幂。e 代表自然对数的底数,其值近似为 2.71828。
实例
在下面的例子中,我们将把 exp() 运用到不同的数值上:
<html><body><script type="text/javascript">document.write(Math.exp(1) + "<br />")document.write(Math.exp(-1) + "<br />")document.write(Math.exp(5) + "<br />")document.write(Math.exp(10) + "<br />")</script></body></html>
输出:
2.7182818284590450.36787944117144233148.413159102576622026.465794806718