FAQ: Eliminating Duplicates in an array

Ahhh true. Fortunately, I think that my code can actually be edited to change that. Huh. I think I might actually try this @ionatan, I’m pretty sure it works for my situation.

You’re also entirely free to make that decision on a case-by-case basis while you’re inserting, you could for example add ages (note the similarity to counting things, each thing is unique, but comes with a count)

It’s not some pre-packaged solution with fixed behaviour. My only point is that keys are unique, the only difference is that instead of searching through all the already existing ones, you get an immediate result because it’s lookup instead of search.
In particular, there’s nothing about the code that you need to keep. What you need to keep is the idea of that you can do lookup without search.
It’s not the behaviour of the particular functions I’m using that should be paid attention to, it’s the data structure, and then you’d pick whatever functions or actions match what you want to do with that data structure.

// expanding use of Array.prototype.map and Object.fromEntries into a loop
const map = {}
for (let person of people) {
  map[person.name] = person

A map does not exclude anything. All members in the examination array have a corresponding element in the resultant array. Filtering is the sure fire way if all we need to know is name and age.

y = x.filter(n => !(n.name === 'Joe' && n.age === 30))

The entry with ‘Joe’ aged, 30 will be gone from the returned array. But so too will ALL the Joe aged 30. So long as we are sure we have removed an isolated instance, we are fine, else this is not a solution.

A map excludes duplicate keys, isn’t that what we’re doing?

How do we know we are removing the correct Joe? Pardon my stupor; guess I’m a little out of my depth.

It’s not ONE action. You have a map. What can you do with a map? You can insert stuff, read stuff, remove stuff.

So when you’re making an insertion, look at the old value, and pick one to keep or combine them.