JavaScript Math.pow() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Method

Definition

Math.pow(base, exponent) returns the base raised to the exponent. For example, Math.pow(2, 3) means 2 × 2 × 2, which is 8.

Read the syntax below, then try the three examples to see the method in action.

Syntax

Call the method on Math. Start with this line.

JavaScript
Math.pow(base, exponent)
CallWhat it does
Math.pow(base, exponent)Returns base raised to the power of exponent.

Built into JavaScript. Call Math.pow(...) on the Math object — no import required. Math is not a constructor, so never write new Math().

Library declarations
JavaScript
Math.pow(base, exponent)

Parameters

ParameterDescription
baseRequired. The number you want to multiply.
exponentRequired. How many times to multiply the base (the power).

Return Value

Return ValueDescription
Numberbase to the power of exponent. Returns NaN if the result is not a real number.

JavaScript Examples

Example 1 — Basic Powers

Pass a base and an exponent. A fractional exponent like 0.5 means square root.

JavaScript
console.log(Math.pow(2, 3)); // 8
console.log(Math.pow(5, 2)); // 25
console.log(Math.pow(9, 0.5)); // 3
Try It Yourself

How It Works

  1. Whole exponent. Math.pow(2, 3) is 2 × 2 × 2 = 8.
  2. Squaring. Math.pow(5, 2) is 5 × 5 = 25.
  3. Fraction exponent. An exponent of 0.5 is the same as a square root, so 9 becomes 3.
  4. Always a number. The result is a normal JavaScript number.

Example 2 — Math.pow() vs the ** Operator

Both give the same answer. The ** operator is shorter and common in modern code.

JavaScript
const a = Math.pow(2, 10);
const b = 2 ** 10;
console.log(a); // 1024
console.log(b); // 1024
console.log(a === b); // true
Try It Yourself

How It Works

  1. Two ways. Math.pow(2, 10) and 2 ** 10 both mean 2 to the power of 10.
  2. Same value. Both print 1024.
  3. Strict compare. a === b is true because the numbers are equal.
  4. Which to use? Use ** for short code. Use Math.pow() when you pass it as a function, like in map.

Example 3 — Negative Exponent, Zero and NaN

A negative exponent gives a fraction. Some inputs have no real answer and return NaN.

JavaScript
console.log(Math.pow(2, -2)); // 0.25
console.log(Math.pow(0, 0)); // 1
console.log(Math.pow(-8, 1 / 3)); // NaN
console.log(Math.pow("abc", 2)); // NaN
Try It Yourself

How It Works

  1. Negative exponent. 2 ** -2 means 1 ÷ (2 × 2), which is 0.25.
  2. Zero to the zero. JavaScript returns 1 for Math.pow(0, 0).
  3. No real answer. A negative base with a fraction exponent returns NaN.
  4. Bad input. The text "abc" cannot become a number, so the result is NaN.

Browser & Runtime Support

Math.pow is part of the first JavaScript standard (ES1) and is Baseline Widely available in every browser and in Node.js.

✓ Baseline · ES1

Math.pow

Supported in Chrome, Firefox, Safari, Edge, Internet Explorer and Node.js for many years. No polyfill needed.

99% Modern browser support
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
Math.pow Excellent

Bottom line: Use Math.pow anywhere. It works in all browsers.

Frequently Asked Questions

Math.pow(base, exponent) returns the base raised to the exponent. Math.pow(2, 3) is 8 because 2 x 2 x 2 = 8.
Yes, they give the same result for numbers. 2 ** 3 and Math.pow(2, 3) are both 8. The ** operator is just shorter.
Use an exponent of 0.5. Math.pow(9, 0.5) is 3. You can also use Math.sqrt(9), which is clearer.
A negative number does not have a real fractional power in JavaScript, so the result is NaN. Use Math.cbrt(-8) to get -2 for a cube root.
It is 1. JavaScript follows the common math rule that any number to the power of 0 is 1, including 0.
All of them. It is part of the very first JavaScript standard and works in every browser and in Node.js.

Next: random()

Learn how to random number from 0 up to 1.

random() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

9 people found this page helpful