[...XXX] 對set的使用
const removeDuplicates = (arr) => [...new Set(arr)];
console.log(removeDuplicates([1, 2, 3, 3, 4, 4, 5, 5, 6]));
// Result: [ 1, 2, 3, 4, 5, 6 ]
{ ...XXX } , [ ...XXX ]
三個點(...)真名叫擴展運算符,是在ES6中新增加的內容,它可以在函數調用/數組構造時,將數組表達式或者string在語法層面展開;
還可以在構造字面量對象時將對象表達式按照key-value的方式展開;