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

# TypeScript Division Assignment

The `/=` (division assignment) operator divides the value of the left operand by the value of the right operand and assigns the resulting quotient to the left operand.

```typescript theme={"dark"}
x /= y;
```

While functionally similar to `x = x / y`, the `/=` operator evaluates the left operand `x` exactly once. This distinction is critical when the left operand is a property access expression with side effects (e.g., `getObj().prop /= 2` invokes `getObj()` only once, whereas `getObj().prop = getObj().prop / 2` invokes it twice).

## Type Constraints

In TypeScript, the compiler enforces strict type rules for the `/=` operator:

* **Operand Types:** Both operands must resolve to type `number`, `bigint`, a numeric `enum`, or `any`.
* **Type Homogeneity:** You cannot mix `bigint` with `number` or `enum` types. However, `number` and numeric `enum` types are interoperable and can be freely mixed in the same operation.
* **Mutability:** The left operand must be a mutable reference (e.g., a variable declared with `let`, `var`, or a writable object property).

## Syntax Visualization

**Standard Number and Enum Division:**

```typescript theme={"dark"}
let num: number = 15;
num /= 3; // num is now 5

enum Divisor { Half = 2 }
let float: number = 5;
float /= Divisor.Half; // float is now 2.5 (freely mixes number and enum)
```

**BigInt Division:**

```typescript theme={"dark"}
let bigNum: bigint = 10n;
bigNum /= 3n; // bigNum is now 3n (fractional components are truncated towards zero)
```

**TypeScript Compiler Errors:**

```typescript theme={"dark"}
const constant: number = 10;
constant /= 2; // Error: Cannot assign to 'constant' because it is a constant.

let numVal: number = 10;
numVal /= "2"; // Error: The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.

let mixed: number = 10;
mixed /= 2n; // Error: Operator '/=' cannot be applied to types 'number' and 'bigint'.
```

## Runtime Evaluation Rules

While TypeScript handles compile-time type checking, the runtime execution follows standard IEEE 754 rules inherited from JavaScript:

* **Division by Zero (`number`):** If the right operand is `0`, the operation evaluates to `Infinity`, `-Infinity`, or `NaN` (if the left operand is also `0`), and assigns this value to the left operand.
* **Division by Zero (`bigint`):** If the right operand is `0n`, the operation throws a runtime `RangeError: Division by zero`.

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