Set: cấu trúc dữ liệu lưu giá trị **duy nhất**, **không thứ tự**, implement khái niệm tập hợp hữu hạn toán học.
Cách 1: Constructor rỗng + add()
let mySet = new Set();
mySet.add(1);
mySet.add(1); // duplicate bỏ qua
console.log(mySet); // Set { 1 }
Cách 2: Truyền iterable vào constructor
Constructor nhận array, set, string, arguments... bất kỳ iterable nào.
let mySet = new Set([1, 2, 1, 3, "a"]);
mySet.add(1);
console.log(mySet); // Set { 1, 2, 3, 'a' }
Ứng dụng: Dedupe array nhanh: [...new Set(arr)].