I'm trying to remove an object from an array if the object exists already in the array. I know how to remove the object but I'm using the includes()
method to find out if the object exists. I can't seem to get this working properly. Here's some code:
const sampleRange = [{from: 500, to: 600}, {from: 700, to: 800}]
const objectFromRange = sampleRange[0]
const objectRange = {from: 500, to: 600}
sampleRange.includes(objectFromRange) => true
sampleRange.includes(objectRange) => false
So why does one sampleRange.includes come out to true
rather the other one comes out as false
? They're the same object.