Math.pow()
Math.pow(base, exponent) number · Added in vES1 · Updated March 13, 2026 · Math Math.pow() returns the base raised to the exponent power — the mathematical exponentiation function. It’s a static method of the Math object, meaning you always call it as Math.pow(base, exponent), not on an instance.
Syntax
Math.pow(base, exponent)
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
base | number | — | The base number |
exponent | number | — | The exponent to raise the base to |
Return Value
The result of raising base to the power of exponent.
Examples
Basic integer powers
Math.pow(2, 3);
// 8 (2³ = 2 × 2 × 2)
Math.pow(5, 2);
// 25 (5² = 5 × 5)
Math.pow(10, 4);
// 10000 (10⁴)
Comparing ** and Math.pow()
ES2016 introduced the ** exponentiation operator, which produces identical results to Math.pow() for most cases:
Math.pow(2, 3) === 2 ** 3; // true (both are 8)
Math.pow(4, 0.5); // 2 (square root)
4 ** 0.5; // 2 (same result)
// The main difference: ** allows chaining without parentheses
(2 ** 3) ** 2; // 64 (2³ = 8, then 8² = 64)
Math.pow(Math.pow(2, 3), 2); // 64 (more verbose)
Prefer ** for readability in modern code, but Math.pow() remains useful for explicit intent or when passing as a callback.
Special values and edge cases
// Zero and negative exponents
Math.pow(5, 0); // 1 (any number to the power of 0 is 1)
Math.pow(5, -2); // 0.04 (5⁻² = 1/25)
// Infinity
Math.pow(2, Infinity); // Infinity
Math.pow(Infinity, 2); // Infinity
Math.pow(0, Infinity); // NaN
// NaN
Math.pow(NaN, 2); // NaN
Math.pow(2, NaN); // NaN
// Negative base with fractional exponent
Math.pow(-4, 0.5); // NaN (no real square root of negative)
Math.pow(-8, 1/3); // -2 (cube root of negative is valid)
// Negative base with integer exponent
Math.pow(-2, 3); // -8 (-2 × -2 × -2)
Math.pow(-2, 4); // 16
The critical edge case: negative base with a fractional exponent returns NaN because there’s no real result. However, fractional exponents that result in an odd-denominator root (like 1/3 for cube root) do work correctly.
Edge Cases Summary
Math.pow(0, 0); // 1 (by convention)
Math.pow(0, positive); // 0
Math.pow(0, negative); // Infinity (1/0)
Math.pow(1, Infinity); // NaN
Math.pow(-1, Infinity); // NaN
Math.pow(1, any); // 1
Performance
Math.pow() and ** are similarly fast on modern engines. Use whichever reads better in context.
See Also
- math::sqrt — Square root
- math::exp — e to the power of a number
- math::log — Natural logarithm