Javascript Reference - JavaScript pow() Method








The pow(x,y) method returns the value of xy.

Browser Support

pow() Yes Yes Yes Yes Yes

Syntax

Math.pow(x, y);

Parameter Values

Parameter Description
x Required. The base
y Required. The exponent




Return Value

return the value of xy.

Example


<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {<!--from   w w  w  .  ja va2s. c  om-->
    document.getElementById("demo").innerHTML = Math.pow(4, 2);
}
</script>

</body>
</html>

The code above is rendered as follows: