JavaScript ** Exponentiation Operator
The exponentiation operator (**) raises the first number to the power of the second. It is the same as Math.pow() but shorter.
Description
The exponentiation operator ** returns the left operand raised to the power of the right. It's equivalent to Math.pow() and also works with BigInt. It is right-associative: 2 ** 3 ** 2 means 2 ** (3 ** 2), which is 512.
A unary operator can't come directly before the base, so -2 ** 2 is a syntax error; write (-2) ** 2 or -(2 ** 2) to make the meaning clear.
Results grow quickly: 2 ** 1024 is already Infinity, and integers above 253 lose precision, so use BigInts, as in 2n ** 100n, when you need exact large integers. A negative exponent gives a fraction, 2 ** -2 is 0.25, and a fractional exponent gives a root, 27 ** (1/3) is roughly 3. The compound assignment form is **=.
Properties
- Operator
**- Category
- Arithmetic
- Precedence
- 13 (1 is lowest, 18 is highest)
- Associativity
- right-to-left
Syntax
x ** yExample
Browser Support
The following information will show you the current browser support for the ** operator. Hover over a browser icon to see the version that first introduced support for this operator.
Desktop





Tablets & Mobile





