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

The `**` operator is the exponentiation operator in JavaScript. It evaluates to the result of raising the first operand (the base) to the power of the second operand (the exponent). It serves as the declarative, syntactic equivalent to the `Math.pow()` method.

```javascript theme={"dark"}
base ** exponent
```

## Evaluation Mechanics

**Associativity**
Unlike most arithmetic operators in JavaScript (which are left-associative), the `**` operator is **right-associative**. When multiple exponentiation operators are chained, the expression is evaluated from right to left.

```javascript theme={"dark"}
2 ** 3 ** 2; 
// Evaluates as: 2 ** (3 ** 2) -> 2 ** 9
// Result: 512

(2 ** 3) ** 2; 
// Evaluates as: 8 ** 2
// Result: 64
```

**Type Coercion**
The operator applies the internal `ToNumeric` abstract operation to both operands. If the operands are not already Numbers or BigInts, JavaScript will implicitly coerce them before evaluation.

```javascript theme={"dark"}
"3" ** "2"; // 9 (Strings coerced to Numbers)
true ** 3;  // 1 (true coerced to 1)
```

## Syntax Constraints with Unary Operators

JavaScript enforces a strict parsing rule to eliminate ambiguity regarding operator precedence between unary operators (such as `+`, `-`, `~`, `!`, `delete`, `void`, `typeof`) and the exponentiation operator.

You cannot place a unary operator immediately before the base operand without explicit grouping using parentheses. Doing so throws a `SyntaxError`.

```javascript theme={"dark"}
-2 ** 2;   // SyntaxError: Unary operator used immediately before exponentiation expression
(-2) ** 2; // 4 (Base is -2)
-(2 ** 2); // -4 (Result of 2**2 is negated)
```

## BigInt Compatibility

The `**` operator natively supports `BigInt` operands. However, standard JavaScript type-mixing rules apply: both the base and the exponent must be of the same type. You cannot mix a `Number` and a `BigInt`.

```javascript theme={"dark"}
2n ** 3n; // 8n
2n ** 3;  // TypeError: Cannot mix BigInt and other types, use explicit conversions
```

*Note: Exponentiating a `BigInt` with a negative `BigInt` exponent throws a `RangeError`, as BigInts cannot represent fractional values.*

## IEEE 754 Edge Cases

Because JavaScript Numbers are double-precision 64-bit floats, the `**` operator adheres to IEEE 754 floating-point specifications for exceptional values:

```javascript theme={"dark"}
NaN ** 0;       // 1 (Any base to the power of 0 is 1)
Infinity ** 0;  // 1
2 ** NaN;       // NaN
2 ** Infinity;  // Infinity
0 ** 0;         // 1
```

## Compound Assignment

The exponentiation operator can be combined with the assignment operator (`=`) to form the exponentiation assignment operator (`**=`), which evaluates the exponentiation and assigns the result to the left operand in a single step.

```javascript theme={"dark"}
let base = 3;
base **= 3; // Equivalent to: base = base ** 3
// base is now 27
```

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