Skip to main content

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.

The !== (strict inequality) operator evaluates whether two operands are not equal, returning a boolean result. Unlike the loose inequality operator (!=), !== does not perform implicit type coercion before comparison; it strictly evaluates both the data type and the value of the operands. It is the exact negation of the strict equality operator (===).
operand1 !== operand2

Evaluation Mechanics

When the JavaScript engine evaluates operand1 !== operand2, it follows a strict set of algorithmic steps:
  1. Type Comparison: If the underlying Type(operand1) is different from Type(operand2), the operator immediately returns true.
  2. Value Comparison (Same Type): If both operands share the same type, the engine evaluates their values:
    • Numbers:
      • If either operand is NaN (Not-a-Number), it returns true. By definition in IEEE 754, NaN is not equal to anything, including itself.
      • If both operands have the same numeric value, it returns false.
      • If one operand is +0 and the other is -0, it returns false (they are considered strictly equal).
    • Strings: Returns false if both strings have the exact same sequence of 16-bit code units; otherwise, it returns true.
    • Booleans: Returns false if both are true or both are false; otherwise, it returns true.
    • BigInts: Returns false if both have the same mathematical integer value; otherwise, it returns true.
    • Symbols: Returns false if both operands are the exact same unique Symbol primitive value; otherwise, it returns true.
    • Objects (including Arrays and Functions): Returns false if both operands hold a reference to the exact same object in memory. If they reference different objects—even if those objects contain identical properties or elements—it returns true.
    • Null / Undefined: null !== null and undefined !== undefined both return false.

Syntax Visualization

// 1. Type Difference (No Coercion)
1 !== "1"                   // true (Number vs String)
0 !== false                 // true (Number vs Boolean)
null !== undefined          // true (Null vs Undefined)

// 2. Value Difference (Same Type)
42 !== 99                   // true
"hello" !== "hello"         // false

// 3. The NaN Exception
NaN !== NaN                 // true (NaN is never equal to NaN)

// 4. Object References
const obj1 = { a: 1 };
const obj2 = { a: 1 };
const obj3 = obj1;

obj1 !== obj2               // true (Different memory references)
obj1 !== obj3               // false (Same memory reference)

// 5. Arrays (Subtype of Object)
[1, 2] !== [1, 2]           // true (Different memory references)

// 6. Symbols
Symbol("x") !== Symbol("x") // true (Different unique primitives)
const sym = Symbol("y");
sym !== sym                 // false (Same unique primitive)
Master JavaScript with Deep Grasping Methodology!Learn More