> ## 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.

# JavaScript Exponentiation Assignment

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.

```javascript theme={"dark"}
LeftHandSideExpression **= AssignmentExpression
```

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.

```javascript theme={"dark"}
// Standard Number evaluation
let base = 3;
base **= 4; 
console.log(base); // 81

// BigInt evaluation
let bigBase = 2n;
bigBase **= 3n; 
console.log(bigBase); // 8n

// Implicit Type Coercion
let strBase = "5";
strBase **= 2; // String "5" is coerced to Number 5
console.log(strBase); // 25
console.log(typeof strBase); // "number" (matches the coerced type, not the original String)
```

## Associativity

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

```javascript theme={"dark"}
let a = 2;
let b = 3;
a **= b **= 2; 

// Evaluates as: a **= (b **= 2)
// b becomes 9
// a becomes 2 ** 9
console.log(a); // 512
console.log(b); // 9
```

## 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.

```javascript theme={"dark"}
let mixedBase = 5n;
// mixedBase **= 2; // Throws TypeError: Cannot mix BigInt and other types

let negBase = -4;
negBase **= 0.5; // Equivalent to the square root of -4
console.log(negBase); // NaN
```

<div
  style={{ 
display: "flex", 
justifyContent: "space-between", 
alignItems: "center", 
maxWidth: "754px", 
padding: "1rem 0",
marginBottom: "24px"
}}
>
  <span style={{ fontWeight: "bold", fontSize: "1.25rem", color: "var(--tw-prose-headings)", fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif" }}>Tired of Poor JavaScript Skills? Fix That With Deep Grasping!</span>

  <a
    href="https://syntblaze.com"
    target="_blank"
    style={{ 
  marginLeft: "24px",
  textDecoration: "none", 
  backgroundColor: "#007AFF",
  color: "#ffffff", 
  padding: "6px 16px", 
  borderRadius: "16px",
  fontSize: "0.9rem",
  fontWeight: "600",
  textAlign: "center",
  transition: "background-color 0.2s ease"
}}
  >
    Learn More
  </a>
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/skill-tracking.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=b9b0305c93bb501c9e767b5c76c88835" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/skill-tracking.png" />

  <img src="https://mintcdn.com/syntblazellc/23tyuOzaWS88qFlc/images/nuggets.png?fit=max&auto=format&n=23tyuOzaWS88qFlc&q=85&s=c86c80197299762989e9b882419b2109" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/nuggets.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/bite-sized-exercises.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=a65f9a38c37ff28ab73ed783c53c60e3" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/bite-sized-exercises.png" />
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap", marginTop: "12px" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/mastery-chain.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=748a1763454713e679260fbb95f154a2" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/mastery-chain.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-previews.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=242f61448ff5dd6deaaab2dccc13b507" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-previews.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-explanations.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=cf0fc1c31f9cd0fc26716781be05fbc9" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-explanations.png" />
</div>
