Array.includes
compares by object identity just like obj === obj2
, so sadly this doesn’t work unless the two items are references to the same object. You can often use Array.prototype.some()
instead which takes a function:
const arr = [{a: 'b'}]
console.log(arr.some(item => item.a === 'b'))
But of course you then need to write a small function that defines what you mean by equality.