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

The `&` (Bitwise AND) operator performs a logical AND operation on each pair of corresponding bits of its numeric operands. When applied to standard JavaScript `Number` values, it evaluates the operands as 32-bit signed integers. When applied to `BigInt` values, it operates on arbitrary-precision integers without size truncation. It returns a `1` in each bit position where both operands have a `1`; otherwise, it returns `0`.

```javascript theme={"dark"}
operand1 & operand2
```

## Execution Mechanics

When the `&` operator is invoked, the JavaScript engine evaluates the operands based on their types using the following sequence:

1. **Type Validation and Coercion**:
   * If both operands are `BigInt` values, they bypass 32-bit conversion and are evaluated as arbitrary-precision integers.
   * If the operands are a mix of `BigInt` and `Number`, the engine throws a `TypeError`.
   * If either operand is a `Symbol`, the engine throws a `TypeError`.
   * For other types, the engine implicitly coerces the operands to standard `Number` values. Strings and Booleans are parsed to their numeric equivalents. Values that resolve to `NaN` (e.g., `undefined`, unparseable strings) or `null` ultimately evaluate to `0` during integer conversion.
2. **Bitwise Alignment and Evaluation**:
   * **For `Number` operands**: The engine applies the internal `ToInt32` abstract operation. Fractional components of floating-point numbers are truncated, and the values are converted to 32-bit signed integers in two's complement format.
   * **For `BigInt` operands**: The engine aligns the arbitrary-precision binary sequences. Conceptually, the shorter sequence is sign-extended (padded with its sign bit) to match the length of the longer sequence.
   * The engine evaluates the aligned sequences bit-by-bit using the following truth table:
     \| Bit A | Bit B | Result (`A & B`) |
     \| :---: | :---: | :---: |
     \|   0   |   0   |   0   |
     \|   0   |   1   |   0   |
     \|   1   |   0   |   0   |
     \|   1   |   1   |   1   |
3. **Return**:
   * For `Number` operands, the resulting 32-bit binary sequence is converted back into a standard JavaScript `Number` (IEEE 754 double-precision 64-bit float) and returned.
   * For `BigInt` operands, the resulting binary sequence is returned as a new `BigInt`.

## Syntax and Evaluation Examples

**Standard Integer Evaluation**

```javascript theme={"dark"}
const a = 12; // Binary: 00000000000000000000000000001100
const b = 10; // Binary: 00000000000000000000000000001010

const result = a & b; 
// Result: 8  // Binary: 00000000000000000000000000001000
```

**BigInt Evaluation (Arbitrary-Precision)**

```javascript theme={"dark"}
// BigInts are not truncated to 32 bits
const bigA = 4294967297n; // Binary: 100000000000000000000000000000001
const bigB = 4294967299n; // Binary: 100000000000000000000000000000011

const result = bigA & bigB;
// Result: 4294967297n
```

**Floating-Point Truncation**

```javascript theme={"dark"}
// Operands are truncated to 14 and 9 via ToInt32 before the bitwise operation
const result = 14.99 & 9.12; 
// 14 Binary: 00000000000000000000000000001110
//  9 Binary: 00000000000000000000000000001001
// Result: 8  (Binary: ...1000)
```

**Implicit Type Coercion**

```javascript theme={"dark"}
"7" & 3;     // String "7" coerces to Number 7. Result: 3
true & 5;    // Boolean true coerces to Number 1. Result: 1
NaN & 15;    // NaN coerces to 0 via ToInt32. Result: 0
null & 8;    // null coerces to 0 via ToInt32. Result: 0
```

**Type Errors (Strict Validation)**

```javascript theme={"dark"}
10n & 5;     // TypeError: Cannot mix BigInt and other types
10 & 5n;     // TypeError: Cannot mix BigInt and other types
Symbol("a") & 1; // TypeError: Cannot convert a Symbol value to a number
```

**Negative Integer Evaluation (Two's Complement)**

```javascript theme={"dark"}
const a = -5; // Binary: 11111111111111111111111111111011
const b = 14; // Binary: 00000000000000000000000000001110

const result = a & b;
// Result: 10 // Binary: 00000000000000000000000000001010
```

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