Set conversion
Set collections can be converted
to arrays. You can also perform the
opposite operation - convert arrays
into Set. Let's see how it's
done.
Set-to-array conversion
Let we have some Set
collection:
javascriptlet set = new Set([1, 2, 3]);
You can convert it to an array using the destructuring technique:
javascriptlet arr = [...set];
Or you can use the Array.from method:
javascriptlet arr = Array.from(set);
Задание 1
Given a Set collection. Convert
it to an array in the two described ways.
Array-to-Set conversion
Let's say we have an array:
javascriptlet arr = [1, 2, 3];
Let's convert it to a Set
collection:
javascriptlet set = new Set(arr);
Задание 2
Given an array. Convert it to a collection.