第一引数の第二引数乗を返します.
Math.pow(x, y)
powメソッドはxのy乗 (xy) を返します.
以下にpowメソッドを使用したサンプルコードを示します.
<html>
<head>
<title>powメソッドのサンプルコード</title>
</head>
<body>
<script type="text/javascript" language="javascript">
document.write(Math.pow(0, 0) + "<br />");
document.write(Math.pow(0, 1) + "<br />");
document.write(Math.pow(2, 2) + "<br />");
document.write(Math.pow(-2, 2) + "<br />");
document.write(Math.pow(-2, 3) + "<br />");
</script>
</body>
</html>
サンプルコードの実行結果は以下のようになります.
1 0 4 4 -8
スポンサード リンク