set 객체는 배열과 유사하지만 수학적 집합의 특성과 일치한다. 따라서 set을 통해 교집합, 합집합, 차집합, 여집합 등을 구현할 수 있다.
<script>
<!--Set객체 생성-->
const set = new Set();
console.log(set); //Set(0) {}
<!--중복된 값은 Set객체에 요소로 저장되지 않는다-->
const set1 = new Set([1, 2, 3, 3]);
console.log(set1); //Set(3) {1, 2, 3}
const set2 = new Set('hello');
console.log(set2); //Set(4) {'h', 'e' 'l' 'o'}
</script>