Uma outra forma de instanciar um Set é utilizando seu construtor
que recebe um array como argumento. Esse argumento é convertido para
um Set.
Sintaxe
let variavel = new Set(array);
Exemplo 2
let array:any = ["fulano","ciclano","beltrano"];
let mset = new Set<string>(array);
console.log(mset);
Saída
Set(3) { 'fulano', 'ciclano', 'beltrano' }
É possível criar um Set a partir da união de um ou mais arrays que
devem ser passados como argumento para o construtor.
Sintaxe
let variavel = new Set( array, array2 );
Exemplo 2
let array1:any = ["fulano","ciclano"]
let array2:any = ["beltrano"];
let mset = new Set<string>([array1,array2]);
console.log(mset);
Saída
Set(2) { [ 'fulano', 'ciclano' ], [ 'beltrano' ] }