Math.pow method
The Math.pow method raises
a number to a given power. The
first parameter is the number,
the second is the power (or exponent)
to raise it to.
Syntax
Math.pow(number, power);
Example
Let's raise the number 3
to the power of 4:
console.log(Math.pow(3, 4));
The code execution result:
81
Example
Let's raise the number 2
to the power of -5:
console.log(Math.pow(2, -5));
The code execution result:
0.03125
Example
There is also the ** operator
that raises numbers to a power:
console.log(3 ** 4);
The code execution result:
81
See also
-
the
Math.sqrtmethod
that takes the square root of a number -
the
exponentiationlesson
that tells about the**operator