DEV Community

Discussion on: How to create an array of unique values in JavaScript using Sets

Collapse
 
kimlongbtc profile image
KimLongUn

"They both accomplish the same thing here so the choice is yours!"

So i dont know if there is some missunderstanding here but as far as i see it they dont work the same as in my case using the spread operator returns

[Set(7)]
0: Set(7) {"anthropological", "security", "surveillance", "technology", "biology", …}

while using Array.from returns

(7) ["anthropological", "security", "surveillance", "technology", "biology", "extra-algorithmic experience", "randomness"]

Collapse
 
neovortex profile image
Neocortexxx • Edited

"They both accomplish the same thing here so the choice is yours!"
Well, actually she refers to the spread operator ('...') and Array.from.
In both cases you still have to use new Set.