Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / JavaScript

Math.pow — raising numbers to a power

Math.pow(base, exponent) raises a base to a specified power and returns a Number. Learn how argument conversion works, how negative and fractional exponents behave, and when the result is NaN.

Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support

Syntax

Math.pow(base, exponent)

Math.pow(base, exponent) computes a power: base is the base and exponent is the exponent. For example, Math.pow(2, 3) produces 8, while Math.pow(2, -2) produces 0.25, the reciprocal of the square. Call the method directly on Math; you do not create an instance of that object.

The method converts base first, then exponent, to Number, so Math.pow("3", 2) produces 9. A BigInt or Symbol argument causes a TypeError. For Number arguments, the result matches the ** operator; unlike Math.pow, that operator also supports two BigInt arguments.

An exponent of 0 produces 1, even when the base is 0 or NaN. A negative, finite, nonzero base with a finite, noninteger exponent produces NaN: Math.pow(-2, 0.5) does not return a complex number. Infinite exponents follow separate rules: Math.pow(-2, Infinity) produces Infinity, while Math.pow(-2, -Infinity) produces +0. Math.pow(0, -1) produces Infinity. General exponentiation results are Number approximations; do not assume exact decimal arithmetic or identical last digits across implementations.

Examples

const results = [
  Math.pow(2, 3),
  Math.pow(2, -2),
  Math.pow("3", 2),
  Math.pow(-2, 0.5),
  Math.pow(NaN, 0)
];
console.log(results.map(String).join("\n"));

Result

8
0.25
9
NaN
1

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources