From da78a9e329e272dedb2400b79a3bdeebff387d47 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:42:17 -0500 Subject: initial commit --- .../reference/global_objects/set/add/index.html | 83 ++++++++ .../reference/global_objects/set/clear/index.html | 76 +++++++ .../reference/global_objects/set/delete/index.html | 98 +++++++++ .../global_objects/set/foreach/index.html | 117 ++++++++++ .../reference/global_objects/set/has/index.html | 93 ++++++++ .../reference/global_objects/set/index.html | 237 +++++++++++++++++++++ .../global_objects/set/prototype/index.html | 86 ++++++++ .../reference/global_objects/set/size/index.html | 69 ++++++ .../reference/global_objects/set/values/index.html | 72 +++++++ 9 files changed, 931 insertions(+) create mode 100644 files/ko/web/javascript/reference/global_objects/set/add/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/set/clear/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/set/delete/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/set/foreach/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/set/has/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/set/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/set/prototype/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/set/size/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/set/values/index.html (limited to 'files/ko/web/javascript/reference/global_objects/set') diff --git a/files/ko/web/javascript/reference/global_objects/set/add/index.html b/files/ko/web/javascript/reference/global_objects/set/add/index.html new file mode 100644 index 0000000000..622b3d876c --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/set/add/index.html @@ -0,0 +1,83 @@ +--- +title: Set.prototype.add() +slug: Web/JavaScript/Reference/Global_Objects/Set/add +tags: + - ECMAScript 2015 + - JavaScript + - Method + - Prototype + - Reference + - set +translation_of: Web/JavaScript/Reference/Global_Objects/Set/add +--- +
{{JSRef}}
+ +

add() 메서드는 Set 개체의 맨 뒤에 주어진 value의 새 요소를 추가합니다.

+ +
{{EmbedInteractiveExample("pages/js/set-prototype-add.html")}}
+ + + +

구문

+ +
mySet.add(value);
+ +

매개변수

+ +
+
value
+
Set 객체에 추가할 요소의 값.
+
+ +

반환 값

+ +

Set 객체.

+ +

예제

+ +

add 메서드 사용하기

+ +
var mySet = new Set();
+
+mySet.add(1);
+mySet.add(5).add('어떤 문자열'); // 계속 붙일 수 있음
+
+console.log(mySet);
+// Set [1, 5, "어떤 문자열"]
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + +
명세상태비고
{{SpecName('ES2015', '#sec-set.prototype.add', 'Set.prototype.add')}}{{Spec2('ES2015')}}최초 정의
{{SpecName('ESDraft', '#sec-set.prototype.add', 'Set.prototype.add')}}{{Spec2('ESDraft')}} 
+ +

브라우저 호환성

+ + + +

{{Compat("javascript.builtins.Set.add")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/javascript/reference/global_objects/set/clear/index.html b/files/ko/web/javascript/reference/global_objects/set/clear/index.html new file mode 100644 index 0000000000..3ecdb98895 --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/set/clear/index.html @@ -0,0 +1,76 @@ +--- +title: Set.prototype.clear() +slug: Web/JavaScript/Reference/Global_Objects/Set/clear +tags: + - ECMAScript 2015 + - JavaScript + - Method + - Prototype + - Reference + - set +translation_of: Web/JavaScript/Reference/Global_Objects/Set/clear +--- +
{{JSRef}}
+ +

clear() 메서드는 Set 객체를 비웁니다.

+ +
{{EmbedInteractiveExample("pages/js/set-prototype-clear.html")}}
+ + + +

구문

+ +
mySet.clear();
+
+ +

예제

+ +

clear() 사용하기

+ +
var mySet = new Set();
+mySet.add(1);
+mySet.add('foo');
+
+mySet.size;       // 2
+mySet.has('foo'); // true
+
+mySet.clear();
+
+mySet.size;       // 0
+mySet.has('bar')  // false
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('ES2015', '#sec-set.prototype.clear', 'Set.prototype.clear')}}{{Spec2('ES2015')}}Initial definition.
{{SpecName('ESDraft', '#sec-set.prototype.clear', 'Set.prototype.clear')}}{{Spec2('ESDraft')}} 
+ +

브라우저 호환성

+ + + +

{{Compat("javascript.builtins.Set.clear")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/javascript/reference/global_objects/set/delete/index.html b/files/ko/web/javascript/reference/global_objects/set/delete/index.html new file mode 100644 index 0000000000..a138736b46 --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/set/delete/index.html @@ -0,0 +1,98 @@ +--- +title: Set.prototype.delete() +slug: Web/JavaScript/Reference/Global_Objects/Set/delete +tags: + - ECMAScript 2015 + - JavaScript + - Method + - Prototype + - Reference + - set +translation_of: Web/JavaScript/Reference/Global_Objects/Set/delete +--- +
{{JSRef}}
+ +

delete() 메서드는 지정한 요소를 Set 객체에서 제거합니다.

+ +
{{EmbedInteractiveExample("pages/js/set-prototype-delete.html")}}
+ + + +

구문

+ +
mySet.delete(value);
+ +

매개변수

+ +
+
value
+
Set 객체에서 제거할 요소의 값.
+
+ +

반환 값

+ +

요소를 제거했으면 true, 아니면 false.

+ +

예제

+ +

delete() 사용하기

+ +
var mySet = new Set();
+mySet.add('foo');
+
+mySet.delete('bar'); // Returns false. No "bar" element found to be deleted.
+mySet.delete('foo'); // Returns true.  Successfully removed.
+
+mySet.has('foo');    // Returns false. The "foo" element is no longer present.
+
+ +

다음 예제는 Set에서 객체를 제거하는 방법을 보입니다.

+ +
var setObj = new Set(); // Create a New Set.
+
+setObj.add({x: 10, y: 20}); // Add object in the set.
+
+setObj.add({x: 20, y: 30}); // Add object in the set.
+
+// Delete any point with `x > 10`.
+setObj.forEach(function(point){
+  if(point.x > 10){
+    setObj.delete(point)
+  }
+})
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('ES2015', '#sec-set.prototype.delete', 'Set.prototype.delete')}}{{Spec2('ES2015')}}Initial definition.
{{SpecName('ESDraft', '#sec-set.prototype.delete', 'Set.prototype.delete')}}{{Spec2('ESDraft')}} 
+ +

브라우저 호환성

+ + + +

{{Compat("javascript.builtins.Set.delete")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/javascript/reference/global_objects/set/foreach/index.html b/files/ko/web/javascript/reference/global_objects/set/foreach/index.html new file mode 100644 index 0000000000..fbfa4963c5 --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/set/foreach/index.html @@ -0,0 +1,117 @@ +--- +title: Set.prototype.forEach() +slug: Web/JavaScript/Reference/Global_Objects/Set/forEach +tags: + - ECMAScript 2015 + - JavaScript + - Method + - Prototype + - Reference + - set +translation_of: Web/JavaScript/Reference/Global_Objects/Set/forEach +--- +
{{JSRef}}
+ +

forEach() 메서드는 주어진 함수를 Set 요소 각각에 대해 삽입 순서대로 실행합니다.

+ +
{{EmbedInteractiveExample("pages/js/set-prototype-foreach.html")}}
+ + + +

구문

+ +
mySet.forEach(callback[, thisArg])
+ +

매개변수

+ +
+
callback
+
각 요소에 대해 실행할 함수. 다음 세 가지 인수를 받습니다.
+
+
+
currentValue, currentKey
+
처리할 현재 요소. Set은 키를 갖지 않으므로 두 인수 모두에 값을 전달합니다.
+
set
+
forEach()를 호출한 Set.
+
+
+
thisArg
+
callback을 실행할 때 this로 사용할 값.
+
+ +

반환 값

+ +

{{jsxref("undefined")}}.

+ +

설명

+ +

forEach() 메서드는 주어진 callbackSet에 존재하는 요소에 대해 한 번씩 실행합니다. 삭제한 값에 대해선 실행하지 않습니다. 그러나 존재하되 값이 {{jsxref("undefined")}}인 경우엔 실행합니다.

+ +

callback은 다음 세 인수와 함께 호출됩니다.

+ + + +

그러나 Set은 키 값을 사용하지 않으므로, 처음 두 개의 매개변수 모두 요소 값을 받습니다. 이는 {{jsxref("Map.foreach", "Map")}}과 {{jsxref("Array.forEach","Array")}}에서 사용하는 forEach()와 동일한 형태를 유지하기 위해서입니다.

+ +

thisArg 매개변수를 forEach()에 제공한 경우 callback을 호출할 때 전달해 this의 값으로 쓰입니다. 전달하지 않으면 undefined를 사용하며, 최종 this 값은 {{jsxref("Operators/this", "함수의 this를 결정하는 평소 규칙", "", 0)}}을 따릅니다.

+ +

forEach()는 각각의 값을 한 번씩 방문하지만, 순회를 끝내기 전에 제거하고 다시 추가한 값은 예외입니다. 방문하기 전 제거한 값에 대해서는 callback을 호출하지 않습니다. forEach()가 끝나기 전 추가한 요소는 방문합니다.

+ +

forEach()Set 객체의 요소에 대해 callback을 실행만 하며 값을 반환하지는 않습니다.

+ +

예제

+ +

Set의 내용물 기록하기

+ +

다음 코드는 Set의 요소 각각을 새로운 줄에 기록합니다.

+ +
function logSetElements(value1, value2, set) {
+    console.log('s[' + value1 + '] = ' + value2);
+}
+
+new Set(['foo', 'bar', undefined]).forEach(logSetElements);
+
+// 콘솔 로그:
+// "s[foo] = foo"
+// "s[bar] = bar"
+// "s[undefined] = undefined"
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('ES2015', '#sec-set.prototype.foreach', 'Set.prototype.forEach')}}{{Spec2('ES2015')}}Initial definition.
{{SpecName('ESDraft', '#sec-set.prototype.foreach', 'Set.prototype.forEach')}}{{Spec2('ESDraft')}} 
+ +

브라우저 호환성

+ + + +

{{Compat("javascript.builtins.Set.forEach")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/javascript/reference/global_objects/set/has/index.html b/files/ko/web/javascript/reference/global_objects/set/has/index.html new file mode 100644 index 0000000000..016da46cfd --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/set/has/index.html @@ -0,0 +1,93 @@ +--- +title: Set.prototype.has() +slug: Web/JavaScript/Reference/Global_Objects/Set/has +tags: + - ECMAScript 2015 + - JavaScript + - Method + - Prototype + - Reference + - set +translation_of: Web/JavaScript/Reference/Global_Objects/Set/has +--- +
{{JSRef}}
+ +

has() 메서드는 Set 객체에 주어진 요소가 존재하는지 여부를 판별해 반환합니다.

+ +
{{EmbedInteractiveExample("pages/js/set-prototype-has.html")}}
+ + + +

구문

+ +
mySet.has(value);
+ +

매개변수

+ +
+
value
+
Set 객체에서 존재 여부를 판별할 값.
+
+ +

반환 값

+ +

Set 객체에 값이 존재하면 true, 아니면 false.

+ +
+

참고: 기술적으로, has()sameValueZero 알고리즘을 사용해 요소의 존재 여부를 판별합니다.

+
+ +

예제

+ +

has() 사용하기

+ +
var mySet = new Set();
+mySet.add('foo');
+
+mySet.has('foo');  // true
+mySet.has('bar');  // false
+
+var set1 = new Set();
+var obj1 = {'key1': 1};
+set1.add(obj1);
+
+set1.has(obj1);        // true
+set1.has({'key1': 1}); // false, 형태만 같은 서로 다른 객체의 참조이기 때문
+set1.add({'key1': 1}); // set1의 요소가 2개로 늘어남
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('ES2015', '#sec-set.prototype.has', 'Set.prototype.has')}}{{Spec2('ES2015')}}Initial definition.
{{SpecName('ESDraft', '#sec-set.prototype.has', 'Set.prototype.has')}}{{Spec2('ESDraft')}} 
+ +

브라우저 호환성

+ + + +

{{Compat("javascript.builtins.Set.has")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/javascript/reference/global_objects/set/index.html b/files/ko/web/javascript/reference/global_objects/set/index.html new file mode 100644 index 0000000000..b8086f89bd --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/set/index.html @@ -0,0 +1,237 @@ +--- +title: Set +slug: Web/JavaScript/Reference/Global_Objects/Set +tags: + - ECMAScript 2015 + - Global Objects + - JavaScript + - Object + - Reference + - set +translation_of: Web/JavaScript/Reference/Global_Objects/Set +--- +
{{JSRef}}
+ +

Set 객체는 자료형에 관계 없이 {{Glossary("Primitive", "원시 값")}}과 객체 참조 모두 유일한 값을 저장할 수 있습니다.

+ +
{{EmbedInteractiveExample("pages/js/set-prototype-constructor.html")}}
+ + + +

구문

+ +
new Set([iterable]);
+ +

매개변수

+ +
+
iterable
+
반복 가능한 객체가 전달된 경우, 그 요소는 모두 새로운 Set에 추가됩니다. 만약 매개변수를 명시하지 않거나 null을 전달하면, 새로운 Set은 비어 있는 상태가 됩니다.
+
+ +

반환 값

+ +

새로운 Set 객체.

+ +

설명

+ +

Set 객체는 값 콜렉션으로, 삽입 순서대로 요소를 순회할 수 있습니다. 하나의 Set 내 값은 한 번만 나타날 수 있습니다. 즉, 어떤 값은 그 Set 콜렉션 내에서 유일합니다.

+ +

값 같음

+ +

Set 내의 값은 유일해야 하기 때문에 값이 같은지 검사를 수행합니다. 이전 ECMAScript 명세에서는 검사 알고리즘이 === 연산자와는 다른 것이었습니다. 특히, +0 === -0이었지만 Set에서는 +0-0이 다른 값이었습니다. 그러나 이는 ECMAScript 2015 명세에서 변경되었습니다. {{anch("브라우저 호환성", "브라우저 호환성")}}의 "Key equality for -0 and 0"을 참고하세요.

+ +

{{jsxref("NaN")}}과 {{jsxref("undefined")}}도 Set에 저장할 수 있습니다. 원래 NaN !== NaN이지만, Set에서 NaNNaN과 같은 것으로 간주됩니다.

+ +

속성

+ +
+
Set.length
+
값이 0인 속성입니다.
+
{{jsxref("Set.@@species", "get Set[@@species]")}}
+
파생 객체를 생성하는데 사용하는 생성자 함수입니다.
+
{{jsxref("Set.prototype")}}
+
Set 생성자의 프로토타입을 나타냅니다. 모든  Set 객체에 속성을 추가할 수 있습니다.
+
+ +

Set 인스턴스

+ +

모든 Set 인스턴스는 {{jsxref("Set.prototype")}}을 상속받습니다.

+ +

속성

+ +

{{page('ko/docs/Web/JavaScript/Reference/Global_Objects/Set/prototype','속성')}}

+ +

메서드

+ +

{{page('ko/docs/Web/JavaScript/Reference/Global_Objects/Set/prototype','메서드')}}

+ +

예제

+ +

Set 객체 사용

+ +
var mySet = new Set();
+
+mySet.add(1); // Set { 1 }
+mySet.add(5); // Set { 1, 5 }
+mySet.add(5); // Set { 1, 5 }
+mySet.add('some text'); // Set { 1, 5, 'some text' }
+var o = {a: 1, b: 2};
+mySet.add(o);
+
+mySet.add({a: 1, b: 2}); // o와 다른 객체를 참조하므로 괜찮음
+
+mySet.has(1); // true
+mySet.has(3); // false, 3은 set에 추가되지 않았음
+mySet.has(5);              // true
+mySet.has(Math.sqrt(25));  // true
+mySet.has('Some Text'.toLowerCase()); // true
+mySet.has(o); // true
+
+mySet.size; // 5
+
+mySet.delete(5); // set에서 5를 제거함
+mySet.has(5);    // false, 5가 제거되었음
+
+mySet.size; // 4, 방금 값을 하나 제거했음
+console.log(mySet);// Set {1, "some text", Object {a: 1, b: 2}, Object {a: 1, b: 2}}
+
+ +

Set 반복

+ +
// set 내 항목에 대해 반복
+// 순서대로 항목을 (콘솔에) 기록: 1, "some text", {"a": 1, "b": 2}
+for (let item of mySet) console.log(item);
+
+// 순서대로 항목을 기록: 1, "some text", {"a": 1, "b": 2}
+for (let item of mySet.keys()) console.log(item);
+
+// 순서대로 항목을 기록: 1, "some text", {"a": 1, "b": 2}
+for (let item of mySet.values()) console.log(item);
+
+// 순서대로 항목을 기록: 1, "some text", {"a": 1, "b": 2}
+// (여기서 key와 value는 같음)
+for (let [key, value] of mySet.entries()) console.log(key);
+
+// Set 객체를 배열 객체로 변환 (Array.from으로)
+var myArr = Array.from(mySet); // [1, "some text", {"a": 1, "b": 2}]
+
+// 다음도 HTML 문서에서 실행하는 경우 작동함
+mySet.add(document.body);
+mySet.has(document.querySelector('body')); // true
+
+// Set과 Array 사이 변환
+mySet2 = new Set([1, 2, 3, 4]);
+mySet2.size; // 4
+[...mySet2]; // [1, 2, 3, 4]
+
+// 교집합은 다음으로 흉내(simulate)낼 수 있음
+var intersection = new Set([...set1].filter(x => set2.has(x)));
+
+// 차집합은 다음으로 흉내낼 수 있음
+var difference = new Set([...set1].filter(x => !set2.has(x)));
+
+// forEach로 set 항목 반복
+mySet.forEach(function(value) {
+  console.log(value);
+});
+
+// 1
+// 2
+// 3
+// 4
+ +

기본 집합 연산 구현

+ +
Set.prototype.isSuperset = function(subset) {
+    for (var elem of subset) {
+        if (!this.has(elem)) {
+            return false;
+        }
+    }
+    return true;
+}
+
+Set.prototype.union = function(setB) {
+    var union = new Set(this);
+    for (var elem of setB) {
+        union.add(elem);
+    }
+    return union;
+}
+
+Set.prototype.intersection = function(setB) {
+    var intersection = new Set();
+    for (var elem of setB) {
+        if (this.has(elem)) {
+            intersection.add(elem);
+        }
+    }
+    return intersection;
+}
+
+Set.prototype.difference = function(setB) {
+    var difference = new Set(this);
+    for (var elem of setB) {
+        difference.delete(elem);
+    }
+    return difference;
+}
+
+//Examples
+var setA = new Set([1, 2, 3, 4]),
+    setB = new Set([2, 3]),
+    setC = new Set([3, 4, 5, 6]);
+
+setA.isSuperset(setB); // => true
+setA.union(setC); // => Set [1, 2, 3, 4, 5, 6]
+setA.intersection(setC); // => Set [3, 4]
+setA.difference(setC); // => Set [1, 2]
+ +

Array 객체와의 관계

+ +
var myArray = ['value1', 'value2', 'value3'];
+
+// Array를 Set으로 변환하기 위해서는 정규 Set 생성자 사용
+var mySet = new Set(myArray);
+
+mySet.has('value1'); // true 반환
+
+// set을 Array로 변환하기 위해 전개 연산자 사용함.
+console.log([...mySet]); // myArray와 정확히 같은 배열을 보여줌
+ +

명세

+ + + + + + + + + + + + + + + + + + + +
명세상태설명
{{SpecName('ES2015', '#sec-set-objects', 'Set')}}{{Spec2('ES2015')}}Initial definition.
{{SpecName('ESDraft', '#sec-set-objects', 'Set')}}{{Spec2('ESDraft')}} 
+ +

브라우저 호환성

+ + + +

{{Compat("javascript.builtins.Set")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/javascript/reference/global_objects/set/prototype/index.html b/files/ko/web/javascript/reference/global_objects/set/prototype/index.html new file mode 100644 index 0000000000..ca6e568bed --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/set/prototype/index.html @@ -0,0 +1,86 @@ +--- +title: Set.prototype +slug: Web/JavaScript/Reference/Global_Objects/Set/prototype +tags: + - ECMAScript 2015 + - JavaScript + - Property + - Reference + - set +translation_of: Web/JavaScript/Reference/Global_Objects/Set +--- +
{{JSRef}}
+ +

Set.prototype 속성은 {{jsxref("Set")}} 생성자의 프로토타입을 나타냅니다.

+ +
{{js_property_attributes(0,0,0)}}
+ +

설명

+ +

{{jsxref("Set")}} 인스턴스는 {{jsxref("Set.prototype")}}에서 상속합니다. 모든 Set 인스턴스에 속성 또는 메서드를 추가하기 위해 생성자의 프로토타입 객체를 사용할 수 있습니다.

+ +

속성

+ +
+
Set.prototype.constructor
+
인스턴스의 프로토타입을 만든 함수를 반환합니다. 이는 기본으로 {{jsxref("Set")}} 함수입니다.
+
{{jsxref("Set.prototype.size")}}
+
Set 객체 내 값의 개수를 반환합니다.
+
+ +

메서드

+ +
+
{{jsxref("Set.add", "Set.prototype.add(value)")}}
+
Set 객체에 주어진 값을 갖는 새로운 요소를 추가합니다. Set 객체를 반환합니다.
+
{{jsxref("Set.prototype.clear()")}}
+
Set 객체에서 모든 요소를 제거합니다.
+
{{jsxref("Set.delete", "Set.prototype.delete(value)")}}
+
value와 관련된 요소를 제거하고 Set.prototype.has(value)가 이전에 반환했던 값을 반환합니다. Set.prototype.has(value)는 그 뒤에 false를 반환합니다.
+
{{jsxref("Set.prototype.entries()")}}
+
삽입 순으로 Set 객체 내 각 값에 대한 [value, value] 배열을 포함하는 새로운 Iterator 객체를 반환합니다. 이는 Map 객체와 비슷하게 유지되므로 여기서 각 항목은 그 keyvalue에 대해 같은 값을 갖습니다.
+
{{jsxref("Set.forEach", "Set.prototype.forEach(callbackFn[, thisArg])")}}
+
삽입 순으로 Set 객체 내에 있는 각 값에 대해 한 번 callbackFn을 호출합니다. thisArg 매개변수가 forEach에 제공된 경우, 이는 각 콜백에 대해 this 값으로 사용됩니다.
+
{{jsxref("Set.has", "Set.prototype.has(value)")}}
+
Set 객체 내 주어진 값을 갖는 요소가 있는지를 주장하는(asserting, 나타내는) boolean을 반환합니다.
+
{{jsxref("Set.prototype.keys()")}}
+
values() 함수와 같은 함수로 삽입 순으로 Set 객체 내 각 요소에 대한 값을 포함하는 새로운 Iterator 객체를 반환합니다.
+
{{jsxref("Set.prototype.values()")}}
+
삽입 순으로 Set 객체 내 각 요소에 대한 을 포함하는 새로운 Iterator 객체를 반환합니다.
+
{{jsxref("Set.prototype.@@iterator()", "Set.prototype[@@iterator]()")}}
+
삽입 순으로 Set 객체 내 각 요소에 대한 을 포함하는 새로운 Iterator 객체를 반환합니다.
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + +
명세상태설명
{{SpecName('ES6', '#sec-set.prototype', 'Set.prototype')}}{{Spec2('ES6')}}초기 정의.
{{SpecName('ESDraft', '#sec-set.prototype', 'Set.prototype')}}{{Spec2('ESDraft')}} 
+ +

브라우저 호환성

+ + + +

{{Compat("javascript.builtins.Set.prototype")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/javascript/reference/global_objects/set/size/index.html b/files/ko/web/javascript/reference/global_objects/set/size/index.html new file mode 100644 index 0000000000..2f437bed4a --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/set/size/index.html @@ -0,0 +1,69 @@ +--- +title: Set.prototype.size +slug: Web/JavaScript/Reference/Global_Objects/Set/size +tags: + - ECMAScript 2015 + - JavaScript + - Property + - Prototype + - Reference + - set +translation_of: Web/JavaScript/Reference/Global_Objects/Set/size +--- +
{{JSRef}}
+ +

size 접근자 속성은 {{jsxref("Set")}} 객체의 원소 수를 반환합니다.

+ +
{{EmbedInteractiveExample("pages/js/set-prototype-size.html")}}
+ + + +

설명

+ +

size의 값은 Set 객체가 가진 원소의 수를 나타내는 정수입니다. size 값의 설정자는 {{jsxref("undefined")}}입니다. 즉 값을 직접 바꿀 수는 없습니다.

+ +

예제

+ +

size 사용하기

+ +
var mySet = new Set();
+mySet.add(1);
+mySet.add(5);
+mySet.add('some text')
+
+mySet.size; // 3
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('ES2015', '#sec-get-set.prototype.size', 'Set.prototype.size')}}{{Spec2('ES2015')}}Initial definition.
{{SpecName('ESDraft', '#sec-get-set.prototype.size', 'Set.prototype.size')}}{{Spec2('ESDraft')}} 
+ +

브라우저 호환성

+ + + +

{{Compat("javascript.builtins.Set.size")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/javascript/reference/global_objects/set/values/index.html b/files/ko/web/javascript/reference/global_objects/set/values/index.html new file mode 100644 index 0000000000..37e019e3da --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/set/values/index.html @@ -0,0 +1,72 @@ +--- +title: Set.prototype.values() +slug: Web/JavaScript/Reference/Global_Objects/Set/values +translation_of: Web/JavaScript/Reference/Global_Objects/Set/values +--- +
{{JSRef}}
+ +

values() method는 Set 객체에 요소가 삽입된 순서대로 각 요소의 값을 순환할 수 있는 Iterator 객체를 반환합니다.

+ +

The keys() method is an alias for this method (for similarity with {{jsxref("Map")}} objects); it behaves exactly the same and returns values of Set elements.

+ +
{{EmbedInteractiveExample("pages/js/set-prototype-values.html")}}
+ + + +

Syntax

+ +
mySet.values();
+
+ +

Return value

+ +

A new Iterator object containing the values for each element in the given Set, in insertion order.

+ +

Examples

+ +

Using values()

+ +
var mySet = new Set();
+mySet.add('foo');
+mySet.add('bar');
+mySet.add('baz');
+
+var setIter = mySet.values();
+
+console.log(setIter.next().value); // "foo"
+console.log(setIter.next().value); // "bar"
+console.log(setIter.next().value); // "baz"
+ +

Specifications

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('ES2015', '#sec-set.prototype.values', 'Set.prototype.values')}}{{Spec2('ES2015')}}Initial definition.
{{SpecName('ESDraft', '#sec-set.prototype.values', 'Set.prototype.values')}}{{Spec2('ESDraft')}} 
+ +

Browser compatibility

+ + + +

{{Compat("javascript.builtins.Set.values")}}

+ +

See also

+ + -- cgit v1.2.3-54-g00ecf