> ## 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 Bitwise AND Assignment

The `&=` (bitwise AND assignment) operator performs a bitwise AND operation between the binary representations of its left and right operands, assigning the computed 32-bit integer result back to the left operand.

```typescript theme={"dark"}
x &= y;
// Equivalent to: x = x & y;
```

## Mechanical Behavior

1. **Type Coercion (`ToInt32`)**: Before the operation occurs, the TypeScript/JavaScript runtime implicitly coerces both operands into 32-bit signed integers. Fractional values are truncated.
2. **Bitwise Evaluation**: The operator compares the operands bit by bit. A bit in the resulting integer is set to `1` if and only if the corresponding bits in *both* operands are `1`. If either bit is `0`, the resulting bit is `0`.
3. **Assignment**: The newly calculated 32-bit integer is assigned to the memory location of the left operand.

## Truth Table

| Bit A (Left) | Bit B (Right) | Result (A & B) |
| :----------- | :------------ | :------------- |
| `1`          | `1`           | `1`            |
| `1`          | `0`           | `0`            |
| `0`          | `1`           | `0`            |
| `0`          | `0`           | `0`            |

## Execution Example

```typescript theme={"dark"}
let a: number = 14; // Binary: 00000000 00000000 00000000 00001110
let b: number = 9;  // Binary: 00000000 00000000 00000000 00001001

a &= b; 

// Bitwise Calculation:
//   00001110 (14)
// & 00001001 (9)
// -------
//   00001000 (8)

console.log(a); // Output: 8
```

## TypeScript Compiler Constraints

While the underlying JavaScript engine will attempt to coerce any type into a number for bitwise operations, the TypeScript compiler enforces strict type safety:

* **Operand Types**: TypeScript requires both the left and right operands to be of type `number` (or `any`). Attempting to use `&=` with strings, booleans, or objects will throw a compilation error (e.g., `TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.`).
* **Mutability**: The left operand must be a mutable reference. It cannot be a constant (`const`) or a read-only property.
* **BigInt Support**: The `&=` operator also supports `bigint` types, provided *both* operands are `bigint`. Mixing `number` and `bigint` will result in a `TS2365` compiler error. When operating on `bigint`, the operation is not restricted to 32 bits.

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