🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Operators › Exponentiation
Exponentiation (**) - JavaScript | MDN
July 8, 2025 - It performs BigInt exponentiation if both operands become BigInts; otherwise, it performs number exponentiation. A TypeError is thrown if one operand becomes a BigInt but the other becomes a number. For both numbers and BigInts, 0 raised to a positive power returns 0, and 0 raised to a power of 0 returns 1. For numbers, 0 raised to a negative number returns Infinity, while -0 raised to a negative number returns -Infinity.
🌐
GitConnected
levelup.gitconnected.com › exponentiation-operator-in-javascript-e38e8255062c
Exponentiation ** operator in Javascript
December 8, 2019 - Exponentiation ** (power) operator in Javascript The ** operator returns the result of the first variable to the power of the second variable. That is, Math.pow(a,b). var a = 2; var b = 5; a ** b; // …
🌐
Educative
educative.io › answers › what-is-the-exponentiation--star-star-operator-in-javascript
What is the exponentiation ** operator in JavaScript?
The exponentiation operator (**) will return the first operand’s power of the second operand. ... The ** operator is right-associative, meaning that the expression is evaluated from the right side of the ** to the left side. ... In the above code, 2 ** 2 is evaluated first.
🌐
YouTube
youtube.com › watch
JavaScript tips — The exponentiation operator (**) - YouTube
The exponentiation operator in JavaScript raises one number to the power of another. This is the same as the Math.pow function, but written in a more natural...
Published   March 3, 2023
🌐
Medium
medium.com › dailyjs › exponentiation-operator-in-javascript-65fda2727308
Exponentiation Operator in JavaScript | by Samantha Ming | DailyJS | Medium
May 7, 2019 - It is characterized by the placement of operators between operands. Other popular infix notations include: + or -. ... I actually like that it’s similar to other languages. Because it makes picking up JavaScript a lot of easier for those folks and they can be up and running very quickly.
🌐
TutorialsPoint
tutorialspoint.com › home › javascript › javascript exponentiation operator
JavaScript Exponentiation Operator
September 1, 2008 - The exponentiation operator in JavaScript is represented as **. The exponentiation operator takes two operands and returns the power of the first operand raised to the second.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Operators › Exponentiation_assignment
Exponentiation assignment (**=) - JavaScript | MDN
July 8, 2025 - The exponentiation assignment (**=) operator performs exponentiation on the two operands and assigns the result to the left operand.
🌐
W3Schools
w3schools.com › howto › howto_js_exponentiation.asp
How To Use JavaScript Exponentiation
Learn how to use JavaScript Exponentiation (**). The exponentiation operator (**) raises the first operand to the power of the second operand:
Find elsewhere
🌐
W3Schools
w3schools.com › jsref › jsref_oper_exponentiation.asp
JavaScript Exponentiation Operator
The exponentiation (**) operator returns the first operand raised to the power of the second operand. The ** operator accepts BigInts as operands. ... If you want to use W3Schools services as an educational institution, team or enterprise, send ...
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › exponentiation-arithmetic-operator-in-javascript
Exponentiation(**) Arithmetic Operator in JavaScript - GeeksforGeeks
July 23, 2025 - JavaScript exponentiation(**) operator in JavaScript is represented by "**" and is used to find the power of the first operator raised to the second operator. This operator is equal to Math.pow() but makes the code simpler and can even accept ...
🌐
2ality
2ality.com › 2016 › 02 › exponentiation-operator.html
ES2016 feature: exponentiation operator (`**`)
The exponentiation operator (**) is an ECMAScript proposal by Rick Waldron. It is at stage 4 (finished) and part of ECMAScript 2016. ... Dr. Axel Rauschmayer Homepage | Mastodon · Exploring JavaScript Book (free online) and exercises
🌐
ESLint
eslint.org › docs › latest › rules › prefer-exponentiation-operator
prefer-exponentiation-operator - ESLint - Pluggable JavaScript Linter
This rule disallows calls to Math.pow and suggests using the ** operator instead. ... /*eslint prefer-exponentiation-operator: "error"*/ const foo = Math.pow(2, 8); const bar = Math.pow(a, b); let baz = Math.pow(a + b, c + d); let quux = Math.pow(-1, n);
🌐
Codú
codu.co › articles › exponentiation-in-javascript-gnnaahao
Exponentiation (**) in JavaScript | by Niall Maher | Codú
For example, 2 ** -3 is 1/8. Always remember the order: the base comes before the **, and the exponent comes after. Unlike Math.pow(), the exponential operator allows you to use BigInt values.
🌐
Biome
biomejs.dev › linter › rules › use-exponentiation-operator
useExponentiationOperator | Biome
code-block.js:1:11 lint/style/useExponentiationOperator FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ℹ Use the ’**’ operator instead of ‘Math.pow’. > 1 │ let baz = Math.pow(a + b, c + d); │ ^^^^^^^^^^^^^^^^^^^^^^ 2 │ ℹ Safe fix: Use the ’**’ operator instead of ‘Math.pow’. 1 │ - let·baz·=·Math.pow(a·+·b,·c·+·d); 1 │ + let·baz·=·(a·+·b)·**·(c·+·d); 2 2 │
🌐
Accreditly
accreditly.io › articles › the-javascript-exponentiation-operator
The JavaScript Exponentiation Operator - Accreditly
November 17, 2025 - Unlock the capabilities of the JavaScript exponentiation operator (`**`) to perform exponential calculations with ease and elegance. Say goodbye to `Math.pow()` and hello to a streamlined syntax.
Top answer
1 of 2
84

Executing it in the browser console says SyntaxError: Unexpected token **.

Because that's the spec. Designed that way to avoid confusion about whether it's the square of the negation of one (i.e. (-1) ** 2), or the negation of the square of one (i.e. -(1 ** 2)). This design was the result of extensive discussion of operator precedence, and examination of how this is handled in other languages, and finally the decision was made to avoid unexpected behavior by making this a syntax error.

2 of 2
41

From the documentation on MDN:

In JavaScript, it is impossible to write an ambiguous exponentiation expression, i.e. you cannot put a unary operator (+/-/~/!/delete/void/typeof) immediately before the base number.

The reason is also explained in that same text:

In most languages like PHP and Python and others that have an exponentiation operator (typically ^ or **), the exponentiation operator is defined to have a higher precedence than unary operators such as unary + and unary -, but there are a few exceptions. For example, in Bash the ** operator is defined to have a lower precedence than unary operators.

So to avoid confusion it was decided that the code must remove the ambiguity and explicitly put the parentheses:

(-1)**2

or:

-(1**2) 

As a side note, the binary - is not treated that way -- having lower precedence -- and so the last expression has the same result as this valid expression:

0-1**2

Exponentiation Precedence in Other Programming Languages

As already affirmed in above quote, most programming languages that have an infix exponentiation operator, give a higher precedence to that operator than to the unary minus.

Here are some other examples of programming languages that give a higher precedence to the unary minus operator:

  • bc
  • VBScript
  • AppleScript
  • COBOL
  • Rexx
  • Orc
🌐
CoreUI
coreui.io › answers › how-to-raise-a-number-to-a-power-in-javascript
How to raise a number to a power in JavaScript · CoreUI
September 28, 2025 - Use Math.pow() or the exponentiation operator (**) to raise numbers to powers efficiently in JavaScript.
🌐
Can I Use
caniuse.com
"Exponentiation operator" | Can I use... Support tables for HTML5, CSS3, etc
"Can I use" provides up-to-date browser support tables for support of front-end web technologies on desktop and mobile web browsers.
🌐
SamanthaMing
samanthaming.com › tidbits › 59-exponentiation-operator
Exponentiation Operator ** | SamanthaMing.com
Finally, there is a more a succinct way to write an Exponentiation Expression using the new ES7 ** notation in JavaScript...
🌐
DEV Community
dev.to › mayallo › exponentiation-in-javascript-a-beginners-guide-5gdj
Exponentiation in JavaScript: A Beginner’s Guide - DEV Community
July 8, 2023 - If, for instance, we raise 2 to the power of 3, we calculate it as 2 * 2 * 2, which gives us the result of 8. In JavaScript, you can use either the ** operator introduced in ES6 or the method Math.pow() when evaluating exponents.