JavaScript уникальные сгруппированные массивы
let user = {
id: 12345,
aCaption: { teams: ["111", "222", "444"] },
bCaptain: { teams: ["444", "222", "111", "444"] }
};
let userA = user.aCaptain?.teams ?? []; // 111, 222, 444
let userB = user.bCaptain?.teams ?? []; // 444, 222, 111, 444
let userAllUniqueTeams = [...new Set([...userA, ...userB])]; // 111, 222, 444
Angry Alpaca