Computer >> Computer tutorials >  >> Programming >> Javascript

How to get the exponent power of a number in JavaScript?


To get the exponent power of a number, use the Math.pow (base, exponent ) method. This method returns the base to the exponent power, that is, base exponent. 

The following are the parameters used in Math.pow() method −

  • base − The base number. 
  • exponents − The exponent to which to raise base.

Example

You can try to run the following code to get the exponent power −

<html>
   <head>
      <title>JavaScript Math pow() Method</title>
   </head>
   <body>
      <script>
         var value = Math.pow(7, 2);
         document.write("First Test Value : " + value );

         var value = Math.pow(8, 8);
         document.write("<br />Second Test Value : " + value );

         var value = Math.pow(-1, 2);
         document.write("<br />Third Test Value : " + value );

         var value = Math.pow(0, 10);
         document.write("<br />Fourth Test Value : " + value );
      </script>
   </body>
</html>