From cb9e359a51c3249d8f5157db69d43fd413ddeda6 Mon Sep 17 00:00:00 2001 From: Florian Merz Date: Thu, 11 Feb 2021 14:45:12 +0100 Subject: unslug ca: move --- .../javascript/reference/classes/static/index.html | 116 +++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 files/ca/web/javascript/reference/classes/static/index.html (limited to 'files/ca/web/javascript/reference/classes/static/index.html') diff --git a/files/ca/web/javascript/reference/classes/static/index.html b/files/ca/web/javascript/reference/classes/static/index.html new file mode 100644 index 0000000000..3255dc1552 --- /dev/null +++ b/files/ca/web/javascript/reference/classes/static/index.html @@ -0,0 +1,116 @@ +--- +title: static +slug: Web/JavaScript/Referencia/Classes/static +translation_of: Web/JavaScript/Reference/Classes/static +--- +
{{jsSidebar("Classes")}}
+ +

La paraula clau static defineix un mètode estàtic per a una classe.

+ +

Sintaxi

+ +
static methodName() { ... }
+ +

Descripció

+ +

Els mètodes estàtics es criden sense realitzar una instantània de la seva classe o instantiating their class nor are they callable when the class is instantiated. Els mètodes estàtics s'utilitzen sovint per crear funcions d'utilitat per una aplicació.

+ +

Exemples

+ +

L'exemple següent mostra diverses coses. Mostra com un mètode estàtic és implementat en una classe i que una classe amb un membre estàtic pot tenir subclasses. Finalment, mostra com es pot i com no es pot cridar un mètode estàtic.

+ +
class Tripple {
+  static tripple(n) {
+    n = n | 1;
+    return n * 3;
+  }
+}
+
+class BiggerTripple extends Tripple {
+  static tripple(n) {
+    return super.tripple(n) * super.tripple(n);
+  }
+}
+
+console.log(Tripple.tripple());
+console.log(Tripple.tripple(6));
+console.log(BiggerTripple.tripple(3));
+var tp = new Tripple();
+console.log(tp.tripple()); //Logs 'tp.tripple is not a function'.
+ +

Especificacions

+ + + + + + + + + + + + + + +
EspecificacióEstatComentaris
{{SpecName('ES6', '#sec-class-definitions', 'Class definitions')}}{{Spec2('ES6')}}Definició inicial.
+ +

Compatibilitat amb navegadors

+ +

{{CompatibilityTable}}

+ +
+ + + + + + + + + + + + + + + + + + + +
CaracterísticaChromeFirefox (Gecko)Internet ExplorerOperaSafari
Suport bàsic{{CompatChrome(42.0)}}Disponible només en el canal Nightly  (desde febrer del 2015){{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
CaracterísticaAndroidChrome per AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Suport bàsic{{CompatUnknown}}{{CompatChrome(42.0)}}Disponible només en el canal Nightly  (desde febrer del 2015){{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
+
+ +

Vegeu també

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