From 4b1a9203c547c019fc5398082ae19a3f3d4c3efe Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:41:15 -0500 Subject: initial commit --- .../reference/global_objects/weakset/index.html | 201 +++++++++++++++++++++ 1 file changed, 201 insertions(+) create mode 100644 files/ca/web/javascript/reference/global_objects/weakset/index.html (limited to 'files/ca/web/javascript/reference/global_objects/weakset/index.html') 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 +--- +
{{JSRef}}
+ +

L'objecte WeakSet permet emmagatzemar dèbilment objects en una col·lecció.

+ +

Sintaxi

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

Paràmetres

+ +
+
iterable
+
Si es pasa un objecte iterable, tots els seus elements seràn afegits al nou WeakSet. null es tractat com a undefined.
+
+ +

Descripció

+ +

Els objectes WeakSet són col·leccions d'objectes. Un objecte al WeakSet només pot passar un cop, és únic en la col·lecció de WeakSet.

+ +

Les principals diferències respecte l'objecte {{jsxref("Set")}} són:

+ + + +

Propietats

+ +
+
WeakSet.length
+
El valor de la propietat length és 0.
+
{{jsxref("WeakSet.prototype")}}
+
Representa el prototip per al constructor de Set. Permet afegir propietats a tots els objectes WeakSet.
+
+ +

Instàncies WeakSet

+ +

Totes les instàncies WeakSet hereten de {{jsxref("WeakSet.prototype")}}.

+ +

Propietats

+ +

{{page('en-US/Web/JavaScript/Reference/Global_Objects/WeakSet/prototype','Properties')}}

+ +

Mètodes

+ +

{{page('en-US/Web/JavaScript/Reference/Global_Objects/WeakSet/prototype','Methods')}}

+ +

Exemples

+ +

Utilitzar l'objecte WeakSet

+ +
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
+
+ +

Especificacions

+ + + + + + + + + + + + + + +
EspecificacióEstatComentaris
{{SpecName('ES6', '#sec-weakset-objects', 'WeakSet')}}{{Spec2('ES6')}}Definició inicial.
+ +

Compatibilitat amb navegadors

+ +

{{CompatibilityTable}}

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
CaracterísticaChromeFirefox (Gecko)Internet ExplorerOperaSafari
Suport bàsic{{CompatChrome(36)}}{{ CompatGeckoDesktop(34) }}{{CompatNo}}{{ CompatOpera(23) }}9
new WeakSet(iterable)38{{ CompatGeckoDesktop(34) }}{{CompatNo}}259
Constructor argument: new WeakSet(null){{CompatVersionUnknown}}{{CompatGeckoDesktop("37")}}{{CompatUnknown}}{{CompatUnknown}}9
Monkey-patched add() in Constructor{{CompatVersionUnknown}}{{CompatGeckoDesktop("37")}}{{CompatUnknown}}{{CompatUnknown}}9
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
CaracterísticaAndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Suport bàsic{{CompatNo}}{{ CompatGeckoMobile(34) }}{{CompatNo}}{{CompatNo}}9
new WeakMap(iterable){{CompatNo}}{{ CompatGeckoMobile(34) }}{{CompatNo}}{{CompatNo}}9
Constructor argument: new WeakSet(null){{CompatUnknown}}{{CompatVersionUnknown}}{{CompatUnknown}}{{CompatUnknown}}9
Monkey-patched add() in Constructor{{CompatUnknown}}{{CompatVersionUnknown}}{{CompatUnknown}}{{CompatUnknown}}9
+
+ +

Vegeu també

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