Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

remove duplicates objects from array javascript

arr.reduce((acc, current) => {
  const x = acc.find(item => item.id === current.id);
  if (!x) {
    return acc.concat([current]);
  } else {
    return acc;
  }
}, []);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #remove #duplicates #objects #array #javascript
ADD COMMENT
Topic
Name
2+6 =