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

The `===` (strict equality) operator evaluates whether two operands are identical in both value and type without performing implicit type coercion. In TypeScript, it enforces compile-time type safety by rejecting comparisons between mutually exclusive types, while behaving identically to JavaScript's strict equality at runtime.

```typescript theme={"dark"}
operand1 === operand2
```

## Compile-Time Behavior

TypeScript performs static analysis on the Left-Hand Side (LHS) and Right-Hand Side (RHS) operands. If the compiler determines that the types of the two operands have no overlap (they are mutually exclusive), it will throw a `ts(2367)` error. By default, TypeScript does not block code emission on type errors; it will still compile and emit the resulting JavaScript file unless the `noEmitOnError` flag is explicitly enabled in the `tsconfig.json`.

```typescript theme={"dark"}
const val1: string = "5";
const val2: number = 5;

// @ts-expect-error
val1 === val2; // TypeScript Error: This condition will always return 'false' since the types 'string' and 'number' have no overlap.
```

If the types share an overlap (e.g., a union type compared to a primitive, or `any`/`unknown` types), the compiler permits the operation and defers to runtime evaluation.

## Runtime Evaluation Mechanics

When evaluating `===`, the JavaScript engine executes the following strict equality comparison algorithm:

1. **Type Comparison:** If the runtime types of the LHS and RHS differ, the operator immediately returns `false`.
2. **Primitive Values:** If both operands are primitives of the same type (`string`, `number`, `boolean`, `bigint`), it returns `true` if their underlying values are identical.
3. **Symbols:** Although `symbol` is a primitive type, every symbol is uniquely instantiated. Two symbols evaluate to `true` if and only if they are the exact same symbol reference. Symbols created with identical descriptions (e.g., `Symbol('text') === Symbol('text')`) evaluate to `false` because they possess unique identities.
4. **Null and Undefined:** `null === null` returns `true`. `undefined === undefined` returns `true`.
5. **Referential Equality (Objects):** If both operands are objects (including arrays and functions), the operator evaluates to `true` if and only if both operands reference the exact same memory location. It does not perform deep value comparison.

```typescript theme={"dark"}
// Primitive evaluation
const str1: string = "text";
const str2: string = "text";
str1 === str2; // true

// Symbol evaluation
const sym1: symbol = Symbol("id");
const sym2: symbol = Symbol("id");
sym1 === sym2; // false (distinct identities)
sym1 === sym1; // true (identical reference)

// Referential equality evaluation
const objA = { id: 1 };
const objB = { id: 1 };
const objC = objA;

objA === objB; // false (distinct memory addresses)
objA === objC; // true (shared memory address)
```

## IEEE 754 Exceptions

The strict equality operator adheres to the IEEE 754 standard for floating-point arithmetic, resulting in two notable mechanical exceptions regarding numbers:

* **NaN (Not-a-Number):** `NaN` is never strictly equal to anything, including itself. `NaN === NaN` evaluates to `false`.
* **Signed Zeros:** Positive zero and negative zero are considered strictly equal. `+0 === -0` evaluates to `true`.

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