Filter only unique values from an array of object javascript

On of the possible solutions depending on your performance / readability needs can be:

arrayOfObj.filter(a => arrayOfObj.filter(obj => obj.style === a.style).length === 1)

Here is a solution in O(n) time complexity. You can iterate all entries to track how often an entry occurs. And then use the filter() function to filter the ones that occur only once.

const arrayOfObj = [
  { name: "a", style: "p" },
  { name: "b", style: "q" },
  { name: "c", style: "q" },
]

const styleCount = {}

arrayOfObj.forEach((obj) => {
  styleCount[obj.style] = (styleCount[obj.style] || 0) + 1
})

const res = arrayOfObj.filter((obj) => styleCount[obj.style] === 1)

console.log(res)