2

Is it possible to have a unique set based on an inner key with out processing it through a function like uniquBy?

export const state = new Set() state.add({name: 'dank meme'}); state.add({name: 'dank meme'}); console.log(state.length) // 2 

How can I make this Set unique by name value?

0

1 Answer 1

0

No, it is not. Adding equal objects to a Set as you do does result in two objects added to the set because they are distinct objects (different references), accidentally with the same content.
You should build a new class, perhaps inheriting from Set, implementing the behaviour you ask.

Sign up to request clarification or add additional context in comments.

1 Comment

Yeah I think I'll do that.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.