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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
---
title: Set.prototype
slug: conflicting/Web/JavaScript/Reference/Global_Objects/Set
translation_of: Web/JavaScript/Reference/Global_Objects/Set
translation_of_original: Web/JavaScript/Reference/Global_Objects/Set/prototype
original_slug: Web/JavaScript/Reference/Global_Objects/Set/prototype
---
<div>{{JSRef}}</div>
<p>The <code><strong>Set</strong></code><strong><code>.prototype</code></strong> property represents the prototype for the {{jsxref("Set")}} constructor.</p>
<div>{{js_property_attributes(0,0,0)}}</div>
<h2 id="Description">Description</h2>
<p>{{jsxref("Set")}} instances inherit from {{jsxref("Set.prototype")}}. You can use the constructor's prototype object to add properties or methods to all <code>Set</code> instances.</p>
<h2 id="Свойства">Свойства</h2>
<dl>
<dt><code>Set.prototype.constructor</code></dt>
<dd>Возвращает функцию, которая создала прототип экземпляра. Это функция {{jsxref("Set")}} по умолчанию.</dd>
<dt>{{jsxref("Set.prototype.size")}}</dt>
<dd>Возвращает количество элементов в объекте <code>Set</code>.</dd>
</dl>
<h2 id="Методы">Методы</h2>
<dl>
<dt>{{jsxref("Set.add", "Set.prototype.add(value)")}}</dt>
<dd>Добавляет новый элемент с переданным значением в <code>Set</code> объект. Возвращает <code>Set</code> объект.</dd>
<dt>{{jsxref("Set.prototype.clear()")}}</dt>
<dd>Removes all elements from the <code>Set</code> object.</dd>
<dt>{{jsxref("Set.delete", "Set.prototype.delete(value)")}}</dt>
<dd>Removes the element associated to the <code>value</code> and returns the value that <code>Set.prototype.has(value)</code> would have previously returned. <code>Set.prototype.has(value)</code> will return <code>false</code> afterwards.</dd>
<dt>{{jsxref("Set.prototype.entries()")}}</dt>
<dd>Returns a new <code>Iterator</code> object that contains<strong> an array of <code>[value, value]</code></strong> for each element in the <code>Set</code> object, in insertion order. This is kept similar to the <code>Map</code> object, so that each entry has the same value for its <em>key</em> and <em>value</em> here.</dd>
<dt>{{jsxref("Set.forEach", "Set.prototype.forEach(callbackFn[, thisArg])")}}</dt>
<dd>Calls <code>callbackFn</code> once for each value present in the <code>Set</code> object, in insertion order. If a <code>thisArg</code> parameter is provided to <code>forEach</code>, it will be used as the <code>this</code> value for each callback.</dd>
<dt>{{jsxref("Set.has", "Set.prototype.has(value)")}}</dt>
<dd>Returns a boolean asserting whether an element is present with the given value in the <code>Set</code> object or not.</dd>
<dt>{{jsxref("Set.prototype.keys()")}}</dt>
<dd>Is the same function as the <strong><code>values()</code></strong> function and returns a new <code>Iterator</code> object that contains the values for each element in the <code>Set</code> object in insertion order.</dd>
<dt>{{jsxref("Set.prototype.values()")}}</dt>
<dd>Returns a new <code>Iterator</code> object that contains the <strong>values</strong> for each element in the <code>Set</code> object in insertion order.</dd>
<dt>{{jsxref("Set.prototype.@@iterator()", "Set.prototype[@@iterator]()")}}</dt>
<dd>Returns a new <code>Iterator</code> object that contains the <strong>values</strong> for each element in the <code>Set</code> object in insertion order.</dd>
</dl>
<h2 id="Specifications">Specifications</h2>
<table class="standard-table">
<tbody>
<tr>
<th scope="col">Specification</th>
<th scope="col">Status</th>
<th scope="col">Comment</th>
</tr>
<tr>
<td>{{SpecName('ES2015', '#sec-set.prototype', 'Set.prototype')}}</td>
<td>{{Spec2('ES2015')}}</td>
<td>Initial definition.</td>
</tr>
<tr>
<td>{{SpecName('ESDraft', '#sec-set.prototype', 'Set.prototype')}}</td>
<td>{{Spec2('ESDraft')}}</td>
<td></td>
</tr>
</tbody>
</table>
<h2 id="Browser_compatibility">Browser compatibility</h2>
<p>{{Compat("javascript.builtins.Set.prototype")}}</p>
<h2 id="See_also">See also</h2>
<ul>
<li>{{jsxref("Map.prototype")}}</li>
</ul>
|