What is Math.power or Math.pow() Method in JavaScript?

What is Math.power or Math.pow() Method in JavaScript and how to use it? Keep on reading!

In this article, you’ll discover the power of JavaScript’s Math.pow() method.

You will learn how to raise numbers to a power, calculate square and cube roots, and work with negative numbers and fractions.

But before that, let’s first understand what is Math.pow() method. 

What is Math.power or Math.pow in JavaScript?

The Math.pow() method in JavaScript is a static method of the Math object, which means it’s called on the Math object itself, not on an instance of the object.

Here’s the illustration:

Math.pow(a,b)=ab

The purpose of Math.pow() method is to take two numbers: a base and an exponent, and calculate the result of raising the base to the power of the exponent.

Syntax

Here’s the syntax of Math.pow() method:

Math.pow(base, exponent)

Parameters

base

This is the base number. It can be any real number.

exponent

This is the exponent or the value to which the base is raised. It can also be any real number.

Return value

The Math.pow() method returns the result of raising the base to the power of the exponent.

If either argument is NaN, or if base is negative and exponent is not an integer, the result will be NaN.

Here’s an example on how to use math.pow in JavaScript:

let base = 5;
let exponent = 3;
let result = Math.pow(base, exponent);  ✅
console.log(result)

Math.pow(5, 3) will calculate 5 raised to the power of 3, which equals to:

125

which is the result of raising 5 (the base) to the power of 3 (the exponent).

Supported browser

✔ Chrome

✔ Edge

✔ Firefox

✔ Internet Explorer

✔ Safari

✔ Opera

Different example usage of Math.pow() method in JavaScript

Here are a few different examples of how you can use the Math.pow() method in JavaScript:

Example 1: Calculating squares and cubes

let square = Math.pow(5, 2); ✅
console.log("The square of 5 is: " + square);

let cube = Math.pow(6, 3);  
console.log("The cube of 6 is: " + cube);

In this example, Math.pow(5, 2) calculates the square of 5, which is 25. Similarly, Math.pow(6, 3) calculates the cube of 6, which is 216.

Output:

The square of 5 is: 25
The cube of 6 is: 216

Example 2: Calculating roots

let squareRoot = Math.pow(49, 0.5); 
console.log("The square root of 49 is: " + squareRoot);

let cubeRoot = Math.pow(27, 1/3); 
console.log("The cube root of 27 is: " + cubeRoot);

In this example, Math.pow(49, 0.5) calculates the square root of 49, which is 7. Similarly, Math.pow(27, 1/3) calculates the cube root of 27, which is 3.

Example 3: Working with negative numbers and fractions

let negativeBase = Math.pow(-5, 2); 
console.log("The result of (-5)^2 is: " + negativeBase);

let fractionExponent = Math.pow(9, 0.5); 
console.log("The square root of 9 is: " + fractionExponent);

In this example, Math.pow(-5, 2) raises -5 to the power of 2, resulting in 25. Similarly, Math.pow(9, 0.5) raises 9 to the power of 0.5 (which is equivalent to taking the square root), resulting in 3.

Output:

The result of (-5)^2 is: 25
The square root of 9 is: 3

Conclusion

The Math.power or Math.pow() method in JavaScript is powerful tool allows us to perform complex calculations like raising numbers to a power, calculating roots, and working with negative numbers and fractions.

With practical examples and clear explanations, we’ve seen how Math.pow() can be effectively used in various scenarios.

We are hoping that this article provides you with enough information that help you understand the Math.power in JavaScript.

If you want to dive into more JavaScript topics, check out the following articles:

Thank you for reading Itsourcecoders 😊.

Frequently Asked Questions

Is JavaScript still worth learning in 2026?
Yes. JavaScript runs on 98% of websites for the front-end, dominates the back-end via Node.js, powers mobile apps through React Native, builds desktop tools through Electron, and is the scripting layer for most AI tooling (LangChain.js, OpenAI SDK, Vercel AI). Whether you target web, mobile, AI, or full-stack capstones, JavaScript is the broadest single language you can learn.
What is the difference between var, let, and const?
var is function-scoped, hoisted to the top of its scope, and can be redeclared, which leads to bugs in modern code. let is block-scoped (only visible inside the nearest {}) and can be reassigned. const is block-scoped and cannot be reassigned, although object contents can still mutate. Default to const for everything, switch to let only when you actually need to reassign, and avoid var in any code written after 2017.
Which JavaScript version should I target in 2026?
Target ES2020 (ES11) as the safe baseline because every modern browser and Node.js 14+ supports it fully. ES2022 adds useful features like top-level await, private class fields with the # prefix, and the .at() array method. If you are writing for older browsers (IE11 or older Android WebViews), transpile down with Babel or use a build tool like Vite, esbuild, or webpack.
What is the best free editor for JavaScript?
Visual Studio Code is the industry standard, free, with built-in IntelliSense, debugger, terminal, Git, and a huge extension marketplace (ESLint, Prettier, GitHub Copilot, Tailwind). Install the JavaScript and TypeScript Nightly extension for the latest language features. JetBrains WebStorm is more powerful and free for students with a verified .edu email. For quick scratchpad work, the Chrome DevTools Sources panel includes a workspace and breakpoint debugger.
How do I run JavaScript locally vs in the browser?
In the browser: open DevTools with F12 (or right-click then Inspect), go to the Console tab, type or paste your code, press Enter. For HTML pages, add a script tag pointing to your .js file. Locally with Node.js: download Node from nodejs.org (LTS version), then run node script.js in your terminal from the file folder. Use the same Node setup for backend capstones, API integrations, and scripts that do not need a browser.
What can I build with JavaScript for my BSIT capstone?
Common BSIT capstones in JavaScript: full-stack web apps using React or Vue on the front-end with Node.js and Express on the back-end (MongoDB or MySQL for the database), real-time chat or notification systems using Socket.io, single-page dashboards with Chart.js or D3.js, cross-platform mobile apps with React Native, AI-powered chatbots using OpenAI SDK and LangChain.js, and Chrome extensions for productivity tools. Add Tailwind CSS for the UI and Vercel or Netlify for free deployment.
Caren Bautista

Technical Writer at PIES IT Solution

Responsible for crafting clear, well-structured, and beginner-friendly content across the platform. Handles the writing, proofreading, and editorial review of tutorials, guides, and documentation to ensure every article is accurate, readable, and easy to follow.

Expertise: Technical Writing · Content Creation · Documentation · Editorial Writing · JavaScript · TypeScript · Python · Python Errors · HTTP Errors · MS Excel  · View all posts by Caren Bautista →

Leave a Comment