Skip to main content
The exponentiation assignment operator (**=) evaluates the result of raising the first operand (the base) to the power of the second operand (the exponent) and assigns that evaluated value back to the first operand.
Mechanically, x **= y is equivalent to x = x ** y, except that the LeftHandSideExpression is evaluated only once. This distinction is relevant when the left side involves complex property accessors or getter/setter side effects.

Type Coercion and Evaluation

Before the exponentiation operation occurs, JavaScript applies the ToNumeric abstract operation to both operands.
  • If the operands are strings, booleans, or objects, they are implicitly coerced into numeric types (Number or BigInt). For example, an object whose valueOf() method returns a BigInt will be coerced into a BigInt, whereas a string like "5" will be coerced into a Number.
  • The operator supports both Number and BigInt primitives.
  • The resulting assigned value will match the type of the operands after they have been coerced to numeric types, not their original evaluated type.

Associativity

Like all assignment operators in JavaScript, **= is right-associative. When chaining multiple assignment operators, evaluation proceeds from right to left.

Exceptions and Edge Cases

  • Type Mixing: Attempting to mix BigInt and Number operands without explicit conversion will throw a TypeError.
  • Negative Bases with Fractional Exponents: If the base is a negative number and the exponent is a fraction, the operation yields NaN because JavaScript does not support imaginary numbers in standard numeric types.
Tired of Poor JavaScript Skills? Fix That With Deep Grasping!Learn More