aboutsummaryrefslogtreecommitdiff
path: root/files/ca/web/javascript/reference/global_objects/weakset/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/ca/web/javascript/reference/global_objects/weakset/index.html')
-rw-r--r--files/ca/web/javascript/reference/global_objects/weakset/index.html201
1 files changed, 201 insertions, 0 deletions
diff --git a/files/ca/web/javascript/reference/global_objects/weakset/index.html b/files/ca/web/javascript/reference/global_objects/weakset/index.html
new file mode 100644
index 0000000000..d1ae3999a6
--- /dev/null
+++ b/files/ca/web/javascript/reference/global_objects/weakset/index.html
@@ -0,0 +1,201 @@
+---
+title: WeakSet
+slug: Web/JavaScript/Reference/Global_Objects/WeakSet
+tags:
+ - ECMAScript6
+ - Experimental
+ - JavaScript
+ - NeedsTranslation
+ - TopicStub
+ - WeakSet
+translation_of: Web/JavaScript/Reference/Global_Objects/WeakSet
+---
+<div>{{JSRef}}</div>
+
+<p><u>L'objecte <strong><code>WeakSet</code></strong> permet emmagatzemar dèbilment <em>objects</em> en una col·lecció.</u></p>
+
+<h2 id="Sintaxi">Sintaxi</h2>
+
+<pre class="syntaxbox"> new WeakSet([iterable]);</pre>
+
+<h3 id="Paràmetres">Paràmetres</h3>
+
+<dl>
+ <dt>iterable</dt>
+ <dd>Si es pasa un <a href="/en-US/docs/Web/JavaScript/Reference/Statements/for...of">objecte iterable</a>, tots els seus elements seràn afegits al nou <code>WeakSet</code>. null es tractat com a undefined.</dd>
+</dl>
+
+<h2 id="Descripció">Descripció</h2>
+
+<p>Els objectes <code>WeakSet</code> són col·leccions d'objectes. Un objecte al <code>WeakSet</code> només pot passar un cop, és únic en la col·lecció de <code>WeakSet.</code></p>
+
+<p>Les principals diferències respecte l'objecte {{jsxref("Set")}} són:</p>
+
+<ul>
+ <li>Al contrari que <code>Sets</code>, <code>WeakSets</code> són <strong>únicament col·leccions d'objectes</strong> i no de valors arbitraris de qualsevol tipus.</li>
+ <li> <code>WeakSet</code> és <em>dèbil (weak)</em>: Les referències a la col·lecció es mantenen dèbilment. SI no hi ha cap altra referència a un objecte emmagatzemat en <code>WeakSet</code>,<u> poden ser recollits com a brossa</u>. Això també vol dir que no hi ha cap llista d'objectes actuals emmagatzemats a la col·lecció. <code>WeakSets</code> no són enumerables.</li>
+</ul>
+
+<h2 id="Propietats">Propietats</h2>
+
+<dl>
+ <dt><code>WeakSet.length</code></dt>
+ <dd>El valor de la propietat <code>length</code> és 0.</dd>
+ <dt>{{jsxref("WeakSet.prototype")}}</dt>
+ <dd>Representa el prototip per al constructor de <code>Set.</code> Permet afegir propietats a tots els objectes <code>WeakSet</code>.</dd>
+</dl>
+
+<h2 id="Instàncies_WeakSet">Instàncies <code>WeakSet</code></h2>
+
+<p>Totes les instàncies <code>WeakSet</code> hereten de {{jsxref("WeakSet.prototype")}}.</p>
+
+<h3 id="Propietats_2">Propietats</h3>
+
+<p>{{page('en-US/Web/JavaScript/Reference/Global_Objects/WeakSet/prototype','Properties')}}</p>
+
+<h3 id="Mètodes">Mètodes</h3>
+
+<p>{{page('en-US/Web/JavaScript/Reference/Global_Objects/WeakSet/prototype','Methods')}}</p>
+
+<h2 id="Exemples">Exemples</h2>
+
+<h3 id="Utilitzar_l'objecte_WeakSet">Utilitzar l'objecte <code>WeakSet</code></h3>
+
+<pre class="brush: js">var ws = new WeakSet();
+var obj = {};
+var foo = {};
+
+ws.add(window);
+ws.add(obj);
+
+ws.has(window); // true
+ws.has(foo); // false, foo no s'ha afegit al conjunt
+
+ws.delete(window); // elimina window del conjunt
+ws.has(window); // false, window ha sigut eliminat
+
+ws.clear(); // buida tot el WeakSet
+</pre>
+
+<h2 id="Especificacions">Especificacions</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">Especificació</th>
+ <th scope="col">Estat</th>
+ <th scope="col">Comentaris</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES6', '#sec-weakset-objects', 'WeakSet')}}</td>
+ <td>{{Spec2('ES6')}}</td>
+ <td>Definició inicial.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Compatibilitat_amb_navegadors">Compatibilitat amb navegadors</h2>
+
+<p>{{CompatibilityTable}}</p>
+
+<div id="compat-desktop">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Característica</th>
+ <th>Chrome</th>
+ <th>Firefox (Gecko)</th>
+ <th>Internet Explorer</th>
+ <th>Opera</th>
+ <th>Safari</th>
+ </tr>
+ <tr>
+ <td>Suport bàsic</td>
+ <td>{{CompatChrome(36)}}</td>
+ <td>{{ CompatGeckoDesktop(34) }}</td>
+ <td>{{CompatNo}}</td>
+ <td>{{ CompatOpera(23) }}</td>
+ <td>9</td>
+ </tr>
+ <tr>
+ <td><code>new WeakSet(iterable)</code></td>
+ <td>38</td>
+ <td>{{ CompatGeckoDesktop(34) }}</td>
+ <td>{{CompatNo}}</td>
+ <td>25</td>
+ <td>9</td>
+ </tr>
+ <tr>
+ <td>Constructor argument: <code>new WeakSet(null)</code></td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatGeckoDesktop("37")}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>9</td>
+ </tr>
+ <tr>
+ <td>Monkey-patched <code>add()</code> in Constructor</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatGeckoDesktop("37")}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>9</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<div id="compat-mobile">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Característica</th>
+ <th>Android</th>
+ <th>Firefox Mobile (Gecko)</th>
+ <th>IE Mobile</th>
+ <th>Opera Mobile</th>
+ <th>Safari Mobile</th>
+ </tr>
+ <tr>
+ <td>Suport bàsic</td>
+ <td>{{CompatNo}}</td>
+ <td>{{ CompatGeckoMobile(34) }}</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatNo}}</td>
+ <td>9</td>
+ </tr>
+ <tr>
+ <td><code>new WeakMap(iterable)</code></td>
+ <td>{{CompatNo}}</td>
+ <td>{{ CompatGeckoMobile(34) }}</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatNo}}</td>
+ <td>9</td>
+ </tr>
+ <tr>
+ <td>Constructor argument: <code>new WeakSet(null)</code></td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>9</td>
+ </tr>
+ <tr>
+ <td>Monkey-patched <code>add()</code> in Constructor</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>9</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<h2 id="Vegeu_també">Vegeu també</h2>
+
+<ul>
+ <li>{{jsxref("Map")}}</li>
+ <li>{{jsxref("Set")}}</li>
+ <li>{{jsxref("WeakMap")}}</li>
+</ul>