Math.pow
Raises a number to a power.
Available since: ES1
Syntax
Math.pow(base, exponent)Parameters
| Parameter | Type | Description |
|---|---|---|
| base | number | The base. |
| exponent | number | The exponent. |
Return value
numberbase raised to the power of exponent.
Examples
Two to the power of ten:
console.log(Math.pow(2, 10));Output:
1024The same with the ** operator:
console.log(2 ** 10);
console.log(9 ** 0.5);Output:
1024
3Notes
Modern code usually uses the ** operator: it is shorter and works the same way.
See also
- Exponentiation (**) — Raises a number to a power.
- Math.sqrt — Returns the square root of a number.
In the tutorial
- Numbers — Numbers in JavaScript — integers and fractions, rounding, the Math object, toFixed and the special values Infinity and NaN.