Answers for "how to remove duplicates in array of objects javascript"

4

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)
Posted by: Guest on October-12-2021

Code answers related to "how to remove duplicates in array of objects javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language