Math.pow()
Returns the base raised to the power of the exponent.
Syntax
Math.pow(base, exponent) Parameters
| Name | Type | Required | Description |
|---|---|---|---|
base | number | Yes | The base number. |
exponent | number | Yes | The exponent to raise the base to. |
Returns
number — base ** exponent, or NaN for invalid inputs (e.g. negative base with fractional exponent).
Examples
console.log(Math.pow(2, 10));
Output
1024
console.log(Math.pow(9, 0.5));
Output
3
Notes
The `**` operator is the modern equivalent (`2 ** 10`). A negative base with a
non-integer exponent returns NaN.
Browser & runtime support
| Environment | Since version |
|---|---|
| chrome | 1.0 |
| firefox | 1.0 |
| safari | 1.0 |
| edge | 12 |
| node | 0.10 |