
The JavaScript ecosystem continues to evolve with new proposals aimed at solving long-standing language limitations. A significant development has recently occurred: the Records and Tuples proposal, which had generated considerable excitement in the developer community, has been officially withdrawn from TC39. In its place, the new Composites proposal has emerged as a promising alternative for addressing one of JavaScript's most persistent challenges: object comparison by value.
The Problem: JavaScript Object Comparison Limitations
To understand why these proposals matter, let's examine a common problem JavaScript developers face. When using objects as keys in Maps or Sets, or when comparing objects directly, JavaScript compares them by reference rather than by value. This leads to unexpected behavior in many situations.
const map = new Map();
// Set a value with an object as the key
map.set({userId: 1, orgId: 2}, [1, 2, 3, 4, 5]);
// Try to retrieve the value with a seemingly identical key
const result = map.get({userId: 1, orgId: 2});
console.log(result); // undefined
Even though both objects have identical properties and values, JavaScript treats them as different keys because they are different object instances in memory. The same issue occurs when comparing objects directly:
console.log({userId: 1, orgId: 2} === {userId: 1, orgId: 2}); // false

The current workaround is to stringify objects when using them as keys, but this approach has significant drawbacks:
- Performance overhead from JSON.stringify operations
- Property order dependency (changing property order changes the string representation)
- Limited to JSON-serializable values
- Loss of type information and structure
// Current workaround using JSON.stringify
const map = new Map();
// Set with stringified object as key
map.set(JSON.stringify({userId: 1, orgId: 2}), [1, 2, 3, 4, 5]);
// Get with stringified object
const result = map.get(JSON.stringify({userId: 1, orgId: 2}));
console.log(result); // [1, 2, 3, 4, 5]
// But this fails if property order changes:
const failedResult = map.get(JSON.stringify({orgId: 2, userId: 1}));
console.log(failedResult); // undefined
The Records and Tuples Proposal: What Happened?
The Records and Tuples proposal was designed to introduce new immutable data structures to JavaScript that would be compared by value rather than by reference. It introduced a special syntax using the hash symbol (#) to create these structures:
// Records and Tuples proposal syntax (now withdrawn)
const map = new Map();
// Create an immutable record with # syntax
map.set(#{userId: 1, orgId: 2}, [1, 2, 3, 4, 5]);
// This would work because records are compared by value
const result = map.get(#{userId: 1, orgId: 2});
console.log(result); // [1, 2, 3, 4, 5]
// This would also be true
console.log(#{userId: 1, orgId: 2} === #{userId: 1, orgId: 2}); // true
Despite its promise, the Records and Tuples proposal had significant limitations:
- Records and tuples could only contain primitives and other records and tuples
- Creation of records required validation of all contained values, causing performance overhead
- The syntax encouraged overuse, potentially leading to performance degradation in applications
- Immutability, while beneficial for some use cases, added constraints that weren't always necessary
These limitations ultimately led to the proposal being withdrawn from the TC39 process.
The Composites Proposal: A New Approach

The new Composites proposal, championed by Ashley Claymore from Bloomberg, takes a different approach to solving the same fundamental problem. Instead of using special syntax, it introduces a global function called Composite:
// Composites proposal syntax
const map = new Map();
// Create a composite object using a function call
map.set(Composite({userId: 1, orgId: 2}), [1, 2, 3, 4, 5]);
// Retrieve using a composite with the same values
const result = map.get(Composite({userId: 1, orgId: 2}));
console.log(result); // [1, 2, 3, 4, 5]
// Property order doesn't matter
const sameResult = map.get(Composite({orgId: 2, userId: 1}));
console.log(sameResult); // [1, 2, 3, 4, 5]
Key Advantages of the Composites Proposal
- Composites can contain any value, not just primitives
- Creation is less expensive as values don't need validation
- Property order doesn't affect equality comparison
- Avoids the performance cost of JSON.stringify for map keys
- Function-based approach discourages overuse compared to special syntax
The Composites proposal is currently at Stage 1 in the TC39 process, which means it's still under active development and discussion. Some aspects remain open for debate, such as whether triple equals (===) should work for comparing composites by value or if a separate method like Composite.equal() should be used instead.
Records and Tuples vs. Composites: Key Differences
While both proposals aim to solve the same problem, they differ in several important ways:
- Content restrictions: Records and tuples can only contain primitives, while composites can contain any value
- Syntax: Records and tuples use special # syntax, while composites use a function call
- Equality comparison: Records and tuples overload the === operator, while composites might use a separate method
- Performance: Composites are designed to be less expensive to create than records and tuples
- Immutability: Records and tuples are deeply immutable, while the immutability approach for composites is still being defined
Practical Implications for JavaScript Developers
For JavaScript developers, the transition from Records and Tuples to the Composites proposal means several things:
- A more flexible solution for object comparison is on the horizon
- The performance concerns of Records and Tuples are being addressed
- Map and Set operations with complex keys will become more intuitive
- Deep equality comparisons will be more accessible without third-party libraries
- The solution will likely be more pragmatic and less dogmatic about immutability
While we wait for the Composites proposal to progress through the TC39 process, developers should continue using existing patterns like JSON.stringify for map keys or leveraging libraries like Immutable.js or lodash's isEqual for deep equality comparisons.
Conclusion
The withdrawal of the Records and Tuples proposal and its replacement with the Composites proposal represents an evolution in JavaScript's approach to solving object comparison challenges. While Records and Tuples offered an elegant syntax, the Composites proposal promises a more flexible, pragmatic solution with better performance characteristics.
As the JavaScript ecosystem continues to evolve, these proposals demonstrate TC39's commitment to addressing developer pain points while carefully considering the performance implications of new language features. The Composites proposal offers hope for a future where JavaScript developers can more easily work with complex data structures without sacrificing performance or resorting to workarounds.
Keep an eye on the Composites proposal as it progresses through the TC39 process, as it could significantly impact how we write JavaScript code in the coming years.
Let's Watch!
JavaScript Composites Proposal Replaces Records and Tuples: What Developers Need to Know
Ready to enhance your neural network?
Access our quantum knowledge cores and upgrade your programming abilities.
Initialize Training Sequence