pow()

The pow() method is used to calculate an exponent power. It returns the value of the first parameter raised to the power of the second parameter. As with all mathematical methods, it is used with a Math object.

syntax:

Math.pow(numberOne, numberTwo)

EXAMPLE

var numberOne = 2;

var numberTwo = 3;

document.write("The value of numberOne raised to the power of numberTwo is : " + Math.pow(numberOne, numberTwo) );

The example begins with the creation of numberOne, which has a value of 2, and numberTwo, which has a value of 3. The document.write statement then writes some descriptive text to the screen along with the result of the Pow() method operation on numberOne and numberTwo. The output is as follows:



The value of numberOne raised to the power of numberTwo is 8