var person = new Map();
person.set([1, 2, 3], 'Kim');
person.set('age', 20);
console.log(person.get('age'));
console.log(person.size); //2
person.delete('age') //자료가 사라짐
console.log(person.get('age')); //undefinded
for (var key of person.keys()) {
console.log(key)
}
//map 자료형에 직접 자료를 집어넣을 땐
var person = new Map([
['name', 'Kim'],
['age', 20]
])
for (var key of person.keys()) {
console.log(key)
}
//set 자료형
var 출석부 = ['john', 'tom', 'andy', 'tom'];
var 출석부2 = new Set(['john', 'tom', 'andy', 'tom']);
출석부2.add('sally');
console.log(출석부2.size)//4 (중복값제외)
// set 자료형 <-> array 자료형
// Array의 중복자료를 제고하고 싶으면?
출석부 = [...출석부2]
console.log(출석부)//4['john', 'tom', 'andy', 'sally']
동기/비동기처리와 콜백함수 (0) | 2021.09.24 |
---|---|
웹브라우저 동작원리 (0) | 2021.09.24 |
Symbol 자료형 (나만 몰래 확인하고 자하는 데이터 저장법) (0) | 2021.09.24 |
for in / for of 반복문과 enumerable, iterable 속성 (0) | 2021.09.24 |
Promise 대신 async/await (0) | 2021.09.24 |