strict equality
Comparing two values with === or !==, which never convert either value to another type first, so values of different types are never equal.
In more detail
Prefer them to == and !=, which convert types in surprising ways: 0 == '' is true. For objects, === checks whether both sides are the same object, not whether their contents match. TypeScript also narrows types on them, so after val !== null the value cannot be null.
Related terms
- timing attack — An attack that works out secret information by measuring how long an operation takes.
- crypto.timingSafeEqual() — A node:crypto function that compares two Buffers of equal length in a time that does not depend on where they differ.
- type narrowing — The compiler refining a broad type to a more specific one inside a block, after a check proves which case applies.
- null — A special value meaning no value or no object, set on purpose to show that something is empty or absent.
Taught in
- Cryptographic Primitives: node:crypto & Ciphers — Node.js Internals & Backend Services
- Typeof Guards, Truthiness And Equality Narrowing — Production TypeScript