Math.pow

一个Math函数,
例如:Math.pow(4,3);返回4的三次幂,
用法:Math.pow(x,y)

x 必需传。底数。必须是数字。

y 必需传。幂数。必须是数字。
如果结果是虚数或负数,则该方法将返回 NaN。如果由于指数过大而引起浮点溢出,则该方法将返回 Infinity我们用函数来写一个类似功能的

<script>
        function arr(n,m) {
            for(var i = 1,a=n; i<m; i++){
                a *=n;
                }
                return a;
        }
        console.log(arr(9,2));


        function arr1(a,b) {
            return a**b;
        }
        console.log(arr1(4,0.5));

        </script>

猜你喜欢

转载自www.cnblogs.com/niuyaomin/p/12085161.html
pow