How can I prevent a Set
object from being populated with duplicate objects?
[
{
prop1: [{value: "val", disabled: true}] (1)
prop2: [{value: [4, 5], disabled: true}] (1)
prop3: [{value: "someOtherValue", disabled: true}] (1)
},
{
prop1: [{value: "val", disabled: true}] (1)
prop2: [{value: [4, 5], disabled: true}] (1)
prop3: [{value: "someOtherValue", disabled: true}] (1)
},
{
prop1: [{value: "otherValue", disabled: true}] (1)
prop2: [{value: [3], disabled: true}] (1)
prop3: [{value: "", disabled: true}] (1)
},
]
So while looping through the array I check if the Set object contains a duplicate, but even if it does, check returns false all the time.
let s = new Set();
//for loop starts here
let check = s.has(obj) // false
if(check == false){
s.add(obj);
}