Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to remove duplicate array object in javascript

const arr = [{id: 1, name: 'one'}, {id: 2, name: 'two'}, {id: 1, name: 'one'}]

const ids = arr.map(o => o.id)
const filtered = arr.filter(({id}, index) => !ids.includes(id, index + 1))

console.log(filtered)
 
PREVIOUS NEXT
Tagged: #remove #duplicate #array #object #javascript
ADD COMMENT
Topic
Name
4+9 =