Javascript examples for Math:pow
The pow() method returns the value of x to the power of y (xy).
Math.pow(x, y)
Parameter | Description |
---|---|
x | Required. The base |
y | Required. The exponent |
A Number, representing the value of x to the power of y (xy)
The following code shows how to use the pow() function:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {// w ww . ja v a 2s . co m var a = Math.pow(0, 1); var b = Math.pow(1, 1); var c = Math.pow(1, 10); var d = Math.pow(3, 3); var e = Math.pow(-3, 3); var f = Math.pow(2, 4); var x = a + "<br>" + b + "<br>" + c + "<br>" + d + "<br>" + e + "<br>" + f; document.getElementById("demo").innerHTML = x; } </script> </body> </html>