Arrays, objects… now ‘composites’?

Arrays, objects… now ‘composites’?

1 Min Read

A nice 9-minute video from Matt Pocock introduces composites and addresses the issue of comparing objects. When two objects appear identical, comparing them results in `false`, and using them as keys is problematic. Records & Tuples had potential but faced performance issues. Composites are more promising.

“`javascript
const pos1 = Composite({ x: 1, y: 4 });
const pos2 = Composite({ x: 1, y: 4 });
Composite.equal(pos1, pos2);
“`

The comparison still returns `true` even if the order of keys is swapped. Although it might not yet be close to becoming a language feature, discussion and research continue.

You might also like