> ## 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 Unsigned Right Shift

The `>>>` (unsigned right shift) operator shifts the binary representation of the first operand to the right by the number of bits specified by the second operand, shifting in zeroes from the left. Unlike the sign-propagating right shift (`>>`), it does not preserve the sign bit, guaranteeing that the evaluated result is always a non-negative 32-bit unsigned integer.

```javascript theme={"dark"}
operand >>> shiftAmount
```

## Technical Mechanics

When the JavaScript engine evaluates a `>>>` operation, it performs the following sequence of internal steps:

1. **Type Coercion:** The left `operand` is converted to a 32-bit integer. For the purposes of this specific operator, it is treated as a 32-bit unsigned integer (`Uint32`).
2. **Shift Masking:** The `shiftAmount` is converted to a 32-bit integer and masked to 5 bits using a bitwise AND (`shiftAmount & 0x1F`). This ensures the actual shift amount is always an integer between `0` and `31` inclusive.
3. **Bit Shifting:** The bits of the left operand are moved to the right by the calculated shift amount.
4. **Zero-Fill:** As bits are shifted to the right, `0` bits are inserted from the far left (the most significant bit position).
5. **Truncation:** Any bits shifted past the 0th position (the least significant bit) are permanently discarded.

## BigInt Incompatibility

In JavaScript, `>>>` is the *only* bitwise operator that does not support `BigInt` operands. Because `BigInt` values represent arbitrary-precision integers and lack a fixed bit-width, the concept of filling zeroes from a fixed leftmost boundary does not apply. Attempting to use `>>>` with a `BigInt` operand throws a `TypeError`.

```javascript theme={"dark"}
const bigValue = 10n;

console.log(bigValue >>> 1n); 
// TypeError: BigInts have no unsigned right shift, use >> instead
```

## Behavioral Examples

### Positive Integers

For positive integers, `>>>` behaves identically to `>>` because the sign bit is already `0`.

```javascript theme={"dark"}
const a = 9; 
// Binary: 00000000000000000000000000001001

const result = a >>> 2; 
// Binary: 00000000000000000000000000000010
// Decimal: 2
```

### Negative Integers

For negative integers, the behavior diverges significantly from `>>`. Negative numbers are represented in 32-bit two's complement, meaning their leftmost bit (sign bit) is `1`. Because `>>>` forces zeroes in from the left, the sign bit is overwritten, resulting in a large positive integer.

```javascript theme={"dark"}
const b = -9;
// Binary: 11111111111111111111111111110111 (Two's complement of -9)

const result = b >>> 2;
// Binary: 00111111111111111111111111111101
// Decimal: 1073741821
```

### Shift Amount Modulo

Because the right operand is masked to 5 bits, shifting by `32` is equivalent to shifting by `0`.

```javascript theme={"dark"}
const c = 255;

console.log(c >>> 32); // 255 (32 & 31 = 0)
console.log(c >>> 33); // 127 (33 & 31 = 1)
```

### Non-Integer Coercion

If the left operand is a non-integer, JavaScript truncates the fractional part during the 32-bit integer conversion before applying the shift. If the operand cannot be converted to a number (e.g., `NaN`, `undefined`), it is coerced to `0`.

```javascript theme={"dark"}
console.log(10.99 >>> 1); // 5 (10.99 is coerced to 10, then shifted)
console.log("42" >>> 1);  // 21 (String "42" is coerced to Number 42, then shifted)
console.log(NaN >>> 1);   // 0
```

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