JS中的Math.pow(a,b)方法

定义和用法
pow() 方法可返回 x 的 y 次幂的值。
语法 Math.pow(x,y)
参数 描述 x 必需。底数。必须是数字。 y 必需。幂数。必须是数字。
返回值 x 的 y 次幂。
说明 如果结果是虚数或负数,则该方法将返回 NaN。如果由于指数过大而引起浮点溢出,则该方法将返回 Infinity。
实例 在下面的例子中,我们将把 pow() 运用到不同的数字组合上:
<script type="text/javascript"> document.write(Math.pow(0,0) + "<br />") document.write(Math.pow(0,1) + "<br />") document.write(Math.pow(1,1) + "<br />") document.write(Math.pow(1,10) + "<br />") document.write(Math.pow(2,3) + "<br />") document.write(Math.pow(-2,3) + "<br />") document.write(Math.pow(2,4) + "<br />") document.write(Math.pow(-2,4) + "<br />") </script> 输出: 1 0 1 1 8 -8 16 16
原文地址:https://www.cnblogs.com/mr-wuxiansheng/p/6683979.html