Removing repetitions from Array using the class Set
Jan 14, 2022
I was watching a course on Udemy and I figure out a very cool way of removing eventual repetitions of elements of an array.
It is the combination of the class Set with the Spread Operator.
Set
Allows storage of unique values of any type.
Example of a set:
Click here to know more about the class Set.
Spread operator
It will serve to spread the elements of the resulting Set.
Example of how the spread operator works:
Click here to learn more about the Spread operator.
Combining both
Now, we can combine both and remove the repetitions: