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>


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM