0%

JS Array Set 互转

array –> set

1
2
let array = [1, 2, 3, 4];
let set = new Set(array);

set –> array

1
2
let demo = new Set([1, 2, 3, 4]);
Array.from(demo);