Answers for "how to remove duplicates from javascript opject array"

-1

remove duplicate object from array javascript

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'}];
Posted by: Guest on August-04-2021

Code answers related to "how to remove duplicates from javascript opject array"

Code answers related to "Javascript"

Browse Popular Code Answers by Language