function uniqSelected(...args){ const out = []; const map = {}; args.forEach(arr => arr.forEach(item => { const {id} = item; if(id in map) return map[id].selected = true; out.push(map[id] = {...item}); })); return out; }