The exponentiation assignment operator (Documentation Index
Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
Use this file to discover all available pages before exploring further.
**=) 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.
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 theToNumeric abstract operation to both operands.
- If the operands are strings, booleans, or objects, they are implicitly coerced into numeric types (
NumberorBigInt). For example, an object whosevalueOf()method returns aBigIntwill be coerced into aBigInt, whereas a string like"5"will be coerced into aNumber. - The operator supports both
NumberandBigIntprimitives. - 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
BigIntandNumberoperands without explicit conversion will throw aTypeError. - Negative Bases with Fractional Exponents: If the base is a negative number and the exponent is a fraction, the operation yields
NaNbecause JavaScript does not support imaginary numbers in standard numeric types.
Master JavaScript with Deep Grasping Methodology!Learn More





