When I was reading the vue source code today, I encountered a writing method that I didn’t understand.
const deduped = [...new Set(pendingPostFlushCbs)]
In my opinion, it is a shallow copy of the array. But why should I convert to Set first，can I have better performance? How should I understand it?
With Set you remove duplicates:
pendingPostFlushCbs = [1,2,5,5,6,8,8,] const deduped = [...new Set(pendingPostFlushCbs)] const deduped1 = [...pendingPostFlushCbs] console.log(deduped) console.log(deduped1)