반응형
자바스크립트에서의 Set
- 중복이 허용되지 않는 객체
// 여러가지 선언 방법
let setType1 = new Set();
let setType2 = new Set([1, 2, 3, 4, 5]);
let setType3 = new Set("");
let setType = new Set([1, 2, 3]);
// 값 추가
setType.add(4); // {1, 2, 3, 4}
setType.add(4); // 4의 값이 중복이기 때문에 추가가 되지 않음
// 값 삭제
setType.delete(2); // {1, 3, 4}
// 존재 여부
setType.has(4); // true
// 초기화
setType.clear(); // {}
// 크기
setType.size(); // 0
반응형
'Computer > Common' 카테고리의 다른 글
🎧 [개발] CS 공부 팁 (0) | 2023.05.14 |
---|---|
[Algorithm] 📚 알고리즘 문제 접근법 (0) | 2023.02.06 |
[VS Code] IDE / Setting / 개발 도구 / vs code 환경 설정 / 초기 설정 / 설치 / 세팅 / 기본 설정 / Extension / 익스텐션 (0) | 2022.09.27 |
[Tistory] 티스토리 인용구 닫기 / 인용구 따옴표 닫기 / 티스토리 블로그 / 인용구 / 따옴표 / quote (0) | 2022.09.26 |
Software Version Rules (버전) (0) | 2022.09.14 |