How can I convert an array to a Set in JavaScript, and is there a way to access or delete elements by key instead of index?

If you want both uniqueness and key-based lookup:

const uniqueSet = new Set(array.map(JSON.stringify)); // To remove duplicates
const finalMap = new Map([...uniqueSet].map(s => {
  const obj = JSON.parse(s);
  return [obj.name, obj];
}));

This is overkill for many use cases but combines deduplication with key-based access.