TheDocumentation Index
Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
Use this file to discover all available pages before exploring further.
=== (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.
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 ats(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.
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:
- Type Comparison: If the runtime types of the LHS and RHS differ, the operator immediately returns
false. - Primitive Values: If both operands are primitives of the same type (
string,number,boolean,bigint), it returnstrueif their underlying values are identical. - Symbols: Although
symbolis a primitive type, every symbol is uniquely instantiated. Two symbols evaluate totrueif and only if they are the exact same symbol reference. Symbols created with identical descriptions (e.g.,Symbol('text') === Symbol('text')) evaluate tofalsebecause they possess unique identities. - Null and Undefined:
null === nullreturnstrue.undefined === undefinedreturnstrue. - Referential Equality (Objects): If both operands are objects (including arrays and functions), the operator evaluates to
trueif and only if both operands reference the exact same memory location. It does not perform deep value comparison.
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):
NaNis never strictly equal to anything, including itself.NaN === NaNevaluates tofalse. - Signed Zeros: Positive zero and negative zero are considered strictly equal.
+0 === -0evaluates totrue.
Master TypeScript with Deep Grasping Methodology!Learn More





