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 equality) operator evaluates whether two operands are identical in both data type and value, strictly bypassing the implicit type coercion performed by the loose equality (==) operator.
operand1 === operand2
Under the hood, === implements the ECMAScript Strict Equality Comparison algorithm. The evaluation follows a rigid set of rules based on the operand types:

1. Type Evaluation

If the operands are of different data types, the engine immediately returns false without attempting to convert them.
1 === '1';        // false (Number vs String)
true === 1;       // false (Boolean vs Number)
null === undefined; // false (Null vs Undefined)

2. Primitive Value Comparison

If both operands are of the same primitive type, they are evaluated by their underlying values:
  • Strings: Returns true if both strings have the exact same sequence of 16-bit unsigned integer values (code units).
  • Booleans: Returns true if both are true or both are false.
  • Null & Undefined: null === null is true, and undefined === undefined is true.
  • Symbols: Returns true only if both operands reference the exact same Symbol instance.
  • BigInt: Returns true if both have the same mathematical integer value.

3. Numeric Edge Cases

When both operands are of type Number, the operator applies specific IEEE 754 floating-point rules:
  • NaN (Not-a-Number) is never equal to anything, including itself.
  • Positive zero (+0) and negative zero (-0) are considered strictly equal.
NaN === NaN; // false
+0 === -0;   // true
5 === 5;     // true

4. Reference Type Comparison (Objects, Arrays, Functions)

When evaluating reference types, === checks for referential equality (identity), not structural equality. It returns true if and only if both operands point to the exact same object instance in memory. Two distinct objects with identical properties and values will evaluate to false.
const objA = { id: 1 };
const objB = { id: 1 };
const objC = objA;

objA === objB; // false (Distinct memory addresses)
objA === objC; // true  (Shared memory address)

[1, 2] === [1, 2]; // false (Distinct array instances)
Master JavaScript with Deep Grasping Methodology!Learn More