JavaScript 入门教程

JavaScript是一门Web编程语言,用来实现网页的交互功能,它和HTML、CSS共同组成了个Web开发的基础工具集合,也是前端开发者必备的技能;学习JavaScript教程可以了解它在网页开发中的所有特性和相关概念,让我们能够更加快速的去开发Web应用。

W3CAPI
1
2025-06-17 11:51:42
文档目录
我的书签
 

pow

JavaScript pow() 方法:Math 对象

详细说明

这个Math对象pow()方法,返回基数的指数次幂,即基数指数幂次方

版本实现

实现于JavaScript 1.0

语法说明

pow(x,y) 
执行一下

参数说明

x, y: 数字


示例:

在以下网页文档中:pow()方法用于计算不同数值的基数到指定指数的幂次方。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>JavaScript Math object - pow() method example</title>
</head>
<body>
<h1 style="color: red">JavaScript Math object : pow() method</h1>
<hr />
<script type="text/javascript">
//This is done to make the following JavaScript code compatible to XHTML. <![CDATA[
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,100) + "<br />");
document.write(Math.pow(2,4) + "<br />");
document.write(Math.pow(-2,3) + "<br />");
document.write(Math.pow(-2,4) + "<br />");
document.write(Math.pow(-2,-2) + "<br />");
x=5
y=5
document.write(Math.pow(x,y));
//]]>
</script>
</body>
</html>

执行一下

在浏览器中查看示例

支持的浏览器

IE浏览器7火狐3.6谷歌Chrome 7Safari 5.0.1 版Opera 10
YesYesYesYesYes

另请参阅:

JavaScript 核心对象、方法及属性。

上一篇:JavaScript min() 方法:Math 对象
下一篇:JavaScript random() 方法:Math 对象

友情提示