How to get unique items.....

Hello, it’s me again :grin:

i have a little problem to get unique items out of an array/object.

This is what i have…
…here the important code-snipet…

for (var i = 0; i < res.items.length; i++) {
 let item = res.items[i]
   console.log("myFilter",myFilter)
   myFilter.push({"ID": res.items[i]._id, "VALUE":res.items[i]})
   console.log("myFilter-ID",myFilter)
   
 //  let uniq = [...new Set(myFilter()]
 //  console.log("Unique",uniq)
}

I have an array/object with dublicates in it. All attempts to use —>

let uniq = [...new Set(myFilter()]

…i got wrong results, or errors.

The end-result what i need, are the unique items by founded unique IDs…
0) —> b72bad46-f39b-4204-902b-76daad3e60cb

  1. —> a5fc5581-4973-4afd-b29e-fe9d11473738
  2. —> 4c6c15f0-69c6-4c71-a4cd-a0cf01cfbf8f

…like this … (the end-result should look like this, but without dublicates)…
CODE:

let item = res.items[i]
myFilter.push(item)
console.log(,myFilter)

Result:

I need just the UNIQUE items from this ARRAY.

What am i missing?

Ok, never mind. I got it to work with another solution.

for (var b = 0; b < MEMcboxes[a].length; b++) {
                        wixData.query(DATABASE)
                        .eq(CBoxes[0], MEMcboxes[0][b])
                        .find()
                        .then(res => {   
 
 for (var i = 0; i < res.items.length; i++) {
 let ITEM = res.items[i]
 let ID = res.items[i]._id
                                console.log("ID = ",ID)
     
 if(myFilter.includes(ID)) {console.log("TRUE")}
 else {console.log("FALSE"), myFilter.push(ID), uniqueItems.push(ITEM)}
                            }
                            console.log("myFilter= ", myFilter)
                            console.log("Unique-Items = " ,uniqueItems)
                            $w('#table1').rows=uniqueItems
                            $w('#table1').refresh()
                        })
                    }