📌  相关文章
📜  从数组 javascript 代码示例中删除重复对象

📅  最后修改于: 2022-03-11 15:02:34.360000             🧑  作者: Mango

代码示例6
let uniqIds = {}, source = [{id:'a'},{id:'b'},{id:'c'},{id:'b'},{id:'a'},{id:'d'}];
let filtered = source.filter(obj => !uniqIds[obj.id] && (uniqIds[obj.id] = true));
console.log(filtered);
// EXPECTED: [{id:'a'},{id:'b'},{id:'c'},{id:'d'}];