The old school way of adding all values of an array into the Set is:
// for the sake of this example imagine this set was created somewhere else
// and I ca
Just post that here for inspiration .. Creating a class that extends Set, and add a addRange method.
class MegaSet extends Set {
constructor(iterable) {
super(iterable);
}
addRange(range) {
for (var elem of range) {
this.add(elem);
}
}
}
const array = [1,2,3,5,5,6];
let mySet = new MegaSet([1,2,3,4]);
mySet.addRange(array);
console.log([...mySet]);