Difference Between Math.pow() and ** in JavaScript
Last Updated :
23 Jul, 2025
JavaScript provides multiple ways to perform exponentiation two of the most commonly used methods are Math.pow() and the exponentiation operator **. While both serve the same purpose of raising a number to a certain power they have different syntaxes and characteristics. The Exponentiation is a mathematical operation involving the two numbers the base and the exponent.
In JavaScript exponentiation can be performed using the Math.pow() function or the exponentiation operator **. Understanding the differences between these two methods can help the developers choose the most appropriate one for their use case.
These are the following topics that we are going to discuss:
What is Math.pow()?
The Math.pow() is a function provided by the Math object in JavaScript to perform the exponentiation. The Math.pow() function returns the base raised to the power of the exponent i.e., base^exponent.
Syntax:
Math.pow(base, exponent)
Example: This example shows the use of Math.pow() function.
JavaScript
let result = Math.pow(2, 3);
console.log(result);
What is **?
The ** operator is the exponentiation operator introduced in the ECMAScript 2016 (ES7). The exponentiation operator ** returns the result of the raising the base to the power of the exponent similar to the Math.pow(). But is is an operator.
Syntax:
base ** exponent
Example: This example shows the use of the ** operator.
JavaScript
let result = 2 ** 3;
console.log(result);
Difference Between Math.pow() and ** in JavaScript
Characteristics | Math.pow() | ** |
|---|
Type | Function | Operator |
|---|
Syntax | Math.pow(base, exponent) | base ** exponent |
|---|
Readability | Less concise | More concise |
|---|
Compatibility | All JavaScript environments | ECMAScript 2016 (ES7) and later |
|---|
Usage in Complex Expressions | Can be less readable | More readable and intuitive |
|---|
Performance | Similar in the most cases | Similar in the most cases |
|---|
Conclusion
Both Math.pow() and ** serve the same purpose of the performing the exponentiation in JavaScript. Math.pow() is a method available in the all JavaScript environments making it suitable for the legacy code. The exponentiation operator ** provides the more concise and readable syntax and is preferred for the modern JavaScript development. Understanding the differences allows the developers to the choose the appropriate method based on their specific needs and the environment they are working in.
Explore
JavaScript Basics
Array & String
Function & Object
OOP
Asynchronous JavaScript
Exception Handling
DOM
Advanced Topics