halfmagic
3/13/2020 - 12:24 PM

remove duplicated objects in an array

const removeDuplicateObjectFromArray = (array, key) => {
  return array.filter((obj, index, self) =>
      index === self.findIndex((el) => (
          el[key] === obj[key]
      ))
  )
}