Set.prototype.add()
Baseline
Widely available
This feature is well established and works across many devices and browser versions. Itโs been available across browsers since โจ2015๋ 7์โฉ.
Set
์ธ์คํด์ค์ add()
๋ฉ์๋๋ ๊ฐ์ ๊ฐ์ธ ์์๊ฐ ์ด Set์ ์๋ค๋ฉด ์ง์ ๋ ๊ฐ๊ณผ ํจ๊ป ์๋ก์ด ์์๋ฅผ ์ด Set์ ์ฝ์
ํฉ๋๋ค.
์๋ํด ๋ณด๊ธฐ
const set1 = new Set();
set1.add(42);
set1.add(42);
set1.add(13);
for (const item of set1) {
console.log(item);
// Expected output: 42
// Expected output: 13
}
๊ตฌ๋ฌธ
js
add(value)
๋งค๊ฐ๋ณ์
value
-
Set
๊ฐ์ฒด์ ์ถ๊ฐํ ์์์ ๊ฐ.
๋ฐํ ๊ฐ
์ถ๊ฐ๋ ๊ฐ์ด ํฌํจ๋ Set
๊ฐ์ฒด.
์์
add
๋ฉ์๋ ์ฌ์ฉํ๊ธฐ
js
const mySet = new Set();
mySet.add(1);
mySet.add(5).add("some text"); // ๊ณ์ ๋ถ์ผ ์ ์์
console.log(mySet);
// Set [1, 5, "some text"]
๋ช ์ธ์
Specification |
---|
ECMAScriptยฎ 2026 Language Specification # sec-set.prototype.add |
๋ธ๋ผ์ฐ์ ํธํ์ฑ
Loadingโฆ