(a: unknown, b: unknown): boolean Deep equality comparison that checks both structure and type.
Key behaviors:
- Compares by constructor to prevent type confusion (security: {} ≠[], {} ≠new Map(), new ClassA() ≠new ClassB())
- Prevents asymmetry bugs: deep_equal(a, b) always equals deep_equal(b, a)
- Compares only enumerable own properties (ignores prototypes, symbols, non-enumerable)
- Special handling for: Date (timestamp), Number/Boolean (boxed primitives), Error (message/name)
- Promises always return false (cannot be meaningfully compared)
- Maps/Sets compare by reference for object keys/values
a
first value to compare
type
unknownb
second value to compare
type
unknownreturns
boolean true if deeply equal, false otherwise