Comment

Comment by wk_end

It works fine on objects.

  const set = new Set();
  const x = { id: 'some object' };
  foo.add(x);
  foo.has(x);
  > true
I'm guessing you're taking issue with the fact that it uses reference equality instead of structural equality, which can definitely be a pain point. There's a proposal to improve the situation with "Records and Tuples" [0], but it's been stuck in committee hell for years.

[0] https://github.com/tc39/proposal-record-tuple

parent wk_end 2 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton