ํ‹ฐ์Šคํ† ๋ฆฌ ๋ทฐ

728x90
// Set ์ƒ์„ฑ
const set = new Set([2, 4, 6]);
console.log(set);


// Set ์‚ฌ์ด์ฆˆ 
console.log(set.size);

// ์กด์žฌํ•˜๋Š”์ง€ ํ™•์ธ
console.log(set.has(2));
console.log(set.has(3));

// ์ˆœํšŒ
set.forEach((item) => console.log(item));
for (const value of set.values()) {
  console.log(value);
}

// ์ถ”๊ฐ€
set.add(6);
console.log(set);
set.add(6);
console.log(set);

// ์‚ญ์ œ
set.delete(6);
console.log(set);

// ์ „๋ถ€ ์‚ญ์ œ
set.clear();
console.log(set);

// Object Set
const obj1 = { name: '๐Ÿ”', price: 3000 };
const obj2 = { name: '๐ŸŸ', price: 500 };
const objs = new Set([obj1, obj2]);
console.log(objs);

// ๋ฐฐ์—ด -> Set
const animals = ['๐Ÿถ', '๐Ÿฑ', '๐Ÿฆ'];
const setAnimals = new Set(animals);
console.log(setAnimals);

// Set -> ๋ฐฐ์—ด
const arrayAnimals = [...setAnimals];
console.log(arrayAnimals);
728x90

'๐ŸŸจ JavaScript > ๊ฐ์ฒด' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

[JavaScript] Object Destructing  (0) 2023.01.19
๊ณต์ง€์‚ฌํ•ญ
์ตœ๊ทผ์— ์˜ฌ๋ผ์˜จ ๊ธ€
์ตœ๊ทผ์— ๋‹ฌ๋ฆฐ ๋Œ“๊ธ€
Total
Today
Yesterday
ยซ   2025/01   ยป
์ผ ์›” ํ™” ์ˆ˜ ๋ชฉ ๊ธˆ ํ† 
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 31
๊ธ€ ๋ณด๊ด€ํ•จ
250x250