(JavaScript) new Set()을 사용하여 배열에 중복이 있는지 확인
새로운 세트(( 반복 가능 )) Set()은 모든 값이 중복되지 않도록 하나씩 수집하는 Collection 객체라고 합니다. let arr = (1,2,2,3,4,4,5); let newCollection = new Set(arr); let newArr = (…newCollection); console.log(newCollection); //{1, 2, 3, 4, 5} console.log(newArr); //(1, 2, 3, 4, 5) if(arr.length !== newCollection.size) console.log(‘중복있음’); //중복있음 위의 예와 같이 arr.length와 newCollection.size를 비교하거나 Set()으로 생성한 Collection 객체를 … Read more