JavaScript Math.pow() | Find Power of a Number

The JavaScript Math.pow() method is used when we need to find the value of x to the power y or the value of xy. For example:

HTML with JavaScript Code
<!DOCTYPE html>
<html>
<body>

   <p id="xyz"></p>
 
   <script>
      let x = 5;
      let y = 3;
      document.getElementById("xyz").innerHTML = Math.pow(x, y);
   </script>
   
</body>
</html>
Output

Since the result of xy or 53 or 5*5*5 is 125, therefore the output produced by above example is 125.

JavaScript Math.pow() Syntax

The syntax of Math.pow() in JavaScript is:

Math.pow(base, exponent)

Both the parameters, that are, base and exponent are required.

The Math.pow() method returns a number which will be the value of baseexponent.

JavaScript Online Test


« Previous Tutorial Next Tutorial »