Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

JavaScript · Function

Math.pow

Math.pow() returns a base raised to an exponent. It is a static Math method that accepts numeric arguments and returns a Number.

How it works

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.

Syntax

Math.pow(base, exponent)

Parameters

NameTypeDescription
basenumberThe base number.
exponentnumberThe exponent number.

Returns

A number representing base taken to the power of exponent. Returns NaN for the documented invalid cases.

Key points

  • Use it to raise a base value to an exponent.
  • Its signature takes exactly a base followed by an exponent.
  • The first parameter supplies the value being raised.
  • The second parameter supplies the power applied to the base.
  • The return value is a JavaScript Number representing the computed power.
  • Several invalid or non-real numeric combinations produce NaN.

Common mistakes

  • Use Math.pow() when a function call is clearer, but remember it cannot perform BigInt exponentiation; the exponentiation operator supports BigInts.
  • The special input Math.pow(NaN, 0) returns 1 rather than NaN.
  • A negative base with a non-integer exponent produces NaN, so fractional roots of negative numbers are not represented as real JavaScript numbers.
  • Do not instantiate Math or call pow() on a custom Math-like object.

Example: Calculate a square's area

const side = 4;
const area = Math.pow(side, 2);
console.log(area); // 16

Raises the side length to the second power to calculate a square's area.

When to use it

Geometric formulas

Compute an area, volume, or other formula involving a known power.

Roots and fractional powers

Apply fractional powers such as square roots through exponent 0.5.

Exponential models

Calculate repeated growth or decay using a numeric exponent.

Interview questions

QWhat does Math.pow() compute?

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.

QHow does Math.pow() differ from **?

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.

QWhen does Math.pow() return NaN?

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.

  • Math
  • Math.sqrt()
  • Math.cbrt()
  • Math.hypot()
  • **

Source: Math.pow() - JavaScript | MDN. Checked 2026-10-15.