Math.pow

Posted niuyaomin

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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>

以上是关于Math.pow的主要内容,如果未能解决你的问题,请参考以下文章