Answers for "remove dupliate objects from array ajavwcript"

-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 "remove dupliate objects from array ajavwcript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language