Title: Object.isEqual() - Deep Structural Equality
Author: Dwight Trujillo
Stage: 0 (Strawman)
Abstract:
Object.isEqual(value1, value2[, options]) provides deep structural equality comparison for ECMAScript. Currently JavaScript has no built-in way to compare objects by structure - developers rely on Lodash (1B+ weekly downloads) or fragile JSON.stringify workarounds. This proposal fills that gap with a native, secure, and configurable solution.
Motivation:
- No native deep equality in JavaScript
- Lodash
_.isEqual: 1B+ weekly npm downloads - 43% of developers cite lack of standard library as major pain point
- JSON.stringify comparison fails with Date, RegExp, Map, Set, NaN, circular references
Basic API:
Object.isEqual({a:1, b:{c:2}}, {a:1, b:{c:2}}); // true
Object.isEqual(new Date('2025-01-01'), new Date('2025-01-01')); // true
Object.isEqual(0, -0, { strict: true }); // false
Object.isEqual(obj1, obj2, { customComparators: { ts: () => true } });
Key Features:
-
SameValueZero by default (NaN = NaN, 0 = -0)
-
Strict mode via { strict: true }
-
Custom per-key or global comparators
-
Circular reference detection
-
All native types supported (Map, Set, Date, RegExp, TypedArrays, etc.)
-
Security hardened (anti-spoofing, cross-realm safe, DoS limits)
-
Zero dependencies
-
Production-ready polyfill available:
npm install object-is-equal
Repository: https://github.com/dwight-trujillo/object-isEqual
Full Proposal: https://github.com/dwight-trujillo/object-isEqual/blob/90834afa31d7e4e214155a71be9cd746799b7ce5/proposal.md
Live Docs: https://dwight-trujillo.github.io/object-isEqual/
Executive Report: https://dwight-trujillo.github.io/object-isEqual/docs/executive-report.html
Prior Art:
-
Lodash
_.isEqual -
Node.js
assert.deepStrictEqual -
Python
==(built-in value comparison) -
Java
Objects.deepEquals()
Does this overlap with existing proposals?
No. Records & Tuples is about immutable value types. Pattern Matching is about structural matching. This proposal is specifically about deep equality comparison.
Seeking:
Stage 0 consideration and a TC39 champion to help advance this proposal.