Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- 인접 형제 선택자 결합
- Array.from()
- Sort
- 배열의 오름차순
- 단방향 연결리스트
- 배열의 내림차순
- 객체
- indexOf
- innerhtml
- Em
- CSS
- visibility : hidden
- for..of
- Link
- 백준알고리즘
- 일반 형제 선택자 결합
- 고차함수
- 가상 요소 선택자
- nth-child()
- 쌍방향 연결리스트
- classList.contains(string)
- 범용 선택자
- 배열과 연결리스트의 차이
- display : none
- invalid assignment left-hand side
- 양방향 연결리스트
- 등차수열의 항 찾기
- map()
- disabled
- filter()
Archives
- Today
- Total
프론트엔드 센트럴파크 (☞゚ヮ゚)☞
set() - 반복문 본문
Set.keys()
Set.values()
let str = new Set("Hello");
console.log(str);
for(let item of str) { // value가 item으로 리턴
console.log(item);
}
key가 없기 때문에 value가 리턴되는 것을 볼 수 있다.
let str = new Set("Hello");
console.log(str);
for(let item of str) {
console.log(item);
}
for(let item of str.keys()) {
console.log(item);
}
for(let item of str.values()) {
console.log(item);
}
key 값이 없기 때문에 세개의 반복문 다 value 값만 출력되는 것을 볼 수 있다.
Set.entries()
let str = new Set("Hello");
console.log(str);
for(let item of str.entries()) {
console.log(item);
key, value 형태로 포맷을 지켜서 반환을 한다.
그 이유는 Map과의 호환성을 지키기 위해서 이다.
key 와 value값 둘 다 같은 값이라고 생각하면 된다.
'Javascript' 카테고리의 다른 글
String.prototype.toString() - 객체의 문자열 표현 (0) | 2022.06.03 |
---|---|
함수표현식 - 기명함수 표현식, 익명함수 표현식 (0) | 2022.06.03 |
set() - 중복제거 (0) | 2022.05.31 |
isArray() 와 Array.from() - 배열인지 알아보고 형변환 (0) | 2022.05.30 |
Map ↔ Object 변환 (0) | 2022.05.30 |
Comments