No, Object.keys(arr.reduce((acc, val) => { acc[val] = val return acc }, { })) is essentially Object.fromEntries(arr.map((val) => [val, val])). So, it is essentially the same method as Set
I would argue that the classical way might be as short, while keeping order, not sure about performance, though.
Does this method keep it's ordering, all the time?
No,
Object.keys(arr.reduce((acc, val) => { acc[val] = val return acc }, { }))
is essentiallyObject.fromEntries(arr.map((val) => [val, val]))
. So, it is essentially the same method asSet
I would argue that the classical way might be as short, while keeping order, not sure about performance, though.
Actually, the third argument of filter callback is
arr
as well, so you can.filter((v,i,a)=>a.indexOf(v)==i)