Geometric formulas
Compute an area, volume, or other formula involving a known power.
JavaScript · Function
Math.pow() returns a base raised to an exponent. It is a static Math method that accepts numeric arguments and returns a Number.
Math.pow() converts its two arguments to numbers and returns the first value raised to the second. It is a static Math method, so call it as Math.pow(base, exponent); its result follows JavaScript number arithmetic, including special NaN, Infinity, and signed-zero cases.
Math.pow(base, exponent)| Name | Type | Description |
|---|---|---|
base | number | The base number. |
exponent | number | The exponent number. |
A number representing base taken to the power of exponent. Returns NaN for the documented invalid cases.
const side = 4;
const area = Math.pow(side, 2);
console.log(area); // 16Raises the side length to the second power to calculate a square's area.
Compute an area, volume, or other formula involving a known power.
Apply fractional powers such as square roots through exponent 0.5.
Calculate repeated growth or decay using a numeric exponent.
It returns the numeric value of base raised to exponent. The arguments are converted to numbers, and the result is a Number.
Follow-up: What happens for a negative base and fractional exponent? It returns NaN because the exponent is not an integer.
Math.pow() is equivalent to the ** operator for Number operands. Unlike Math.pow(), the operator also accepts BigInt operands.
Follow-up: Can Math.pow() calculate with BigInts? No; it only accepts numbers, so use ** for BigInt exponentiation.
It returns NaN when the exponent is NaN, when the base is NaN and the exponent is not zero, when ±1 is raised to ±Infinity, or when a negative base has a non-integer exponent.
Follow-up: What is the notable NaN exception? Math.pow(NaN, 0) returns 1.
MathMath.sqrt()Math.cbrt()Math.hypot()**