在JS中,2的4次方如何计算?

JavaScript010

在JS中,2的4次方如何计算?,第1张

需要准备的材料分别是:电脑、html编辑器、浏览器。

1、首先,打开html编辑器,新建html文件,例如:index.html。

2、在index.html的<script>标签中,再输入js代码:var a = Math.pow(2, 4)document.body.innerText = a。

3、浏览器运行index.html页面,此时会打印出js对2的4次方的计算结果。

1)如何计算乘方

题一:3的4次方(不会打,请原谅 ==!!!)

3的4次方=3*3*3*3

var a = Math.pow(3,4)

console.log(a)

说明:Math.pow()是用来计算乘方的语法

注意:Math的M是大写;

题二:3的4*5次方

var a =Math.pow(3,4*5)

console.log(a)

2)如何计算根号

题目:根号81

var a = Math.sqrt(81)

console.log(a)