๐ Map
๐ฏ new Map() โก๏ธ Map ์์ฑ
let map = new Map();
let map = new Map([[1, 2], [3, 4], [5, 6]]);
let userinfo = new Map([['name', "John"], ['name', "Sara"], ['age', "40"]]);
๐ฏ map.set() โก๏ธ Map์ ์๋ฃ ์
๋ ฅ/์ ๊ฑฐ/์์
map.set('key', 'value');
๐ฏ map.has() โก๏ธ Map์ key ์๋์ง ํ์ธํ๊ธฐ
map.has('key');
๐ฏ map.get() โก๏ธ Map์ value ๊ฐ์ ธ์ค๊ธฐ
map.get('key');
๐ Set
๐ฏ new Set() โก๏ธ Set ์์ฑ
let set = new Set();
let set1 = new Set([1, 2, 1, 3, 7]);
let set2 = new Set([{name: "John"}, {name: "Sara"}, {age: "40"}])
๐ฏ set.has() โก๏ธ Set ์๋ฃ ๊บผ๋ด๋ณด๊ธฐ
set1;
set1.has(3);
for (let user of set2) {
console.log(user);
}
for (let user of set2) {
console.log(user.name);
}
for (let user of set2) {
console.log(user.age);
}
๐ฏ set.add()/set.delete() โก๏ธ Set์ ์๋ฃ ์
๋ ฅ/์ ๊ฑฐ/์์
set.add(8);
set.delete(8);
๐ฏ set.size โก๏ธ Set ํฌ๊ธฐ
set1.size