Have tried set to find uniques in a simple array and it works great, but would this work if its a nested array, an array of objects or multi dimensional arrays?
since arrays and objects are reference type it may work in some cases, ex:
letx={a:1};lety=[];y.push(x);y.push(x);console.log(Array.from(newSet(y)));// will output [{a: 1}]
but if you want an array of objects with the same structure it wont work:
console.log(Array.from(newSet([{a:1},{a:1}])))// will output [{a: 1}, {a: 1}]
if you want to compare structures it will mostly depend on the kind of array you have, for example an array of database documents may be filtered based on _id or name:
in most cases the arrays items will have a predetermined format, it's very rare to need multi purpose duplicate remover, at least i didn't need one till now, it also may do some checks that aren't really necessary for what you want to do, which may be bad for performance, but may be helpful to speed up development.
Have tried set to find uniques in a simple array and it works great, but would this work if its a nested array, an array of objects or multi dimensional arrays?
since arrays and objects are reference type it may work in some cases, ex:
but if you want an array of objects with the same structure it wont work:
if you want to compare structures it will mostly depend on the kind of array you have, for example an array of database documents may be filtered based on _id or name:
in most cases the arrays items will have a predetermined format, it's very rare to need multi purpose duplicate remover, at least i didn't need one till now, it also may do some checks that aren't really necessary for what you want to do, which may be bad for performance, but may be helpful to speed up development.
This is interesting, passing objects with same reference vs passing same objects with different references.
Thanks for the explanation :)