How to use the pow in JavaScript

In this article we will discuss about how to use the pow() Method in JavaScript.
  • 1930

The pow() Method of the Math class is used to return the base to the exponent power . In this method we need to pass two parameter first is base to which power will be calculated and the other is exponent value. The syntax is as follows:

Syntax:

Math.pow(Base, exponent);

Here we will calculate Base exponent.

JavaScript Code:

<html>

<head>

    <title>JavaScript Math pow() Method</title>

</head>

<body>

    <script type="text/javascript">

 

        var power = Math.pow(2, 4);

        document.write("First Test Value : " + power);

 

        var power = Math.pow(3, 2);

        document.write("<br />Second Test Value : " + power);

 

        var power = Math.pow(-1, 4);

        document.write("<br />Third Test Value : " + power);

 

        var power = Math.pow(0, 2);

        document.write("<br />Fourth Test Value : " + power);

    </script>

</body>

</html>

Output:

 java2.jpg

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.