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 --- .../reference/global_objects/array/of/index.html | 120 +++++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 files/ca/web/javascript/reference/global_objects/array/of/index.html (limited to 'files/ca/web/javascript/reference/global_objects/array/of/index.html') diff --git a/files/ca/web/javascript/reference/global_objects/array/of/index.html b/files/ca/web/javascript/reference/global_objects/array/of/index.html new file mode 100644 index 0000000000..efe2d96abd --- /dev/null +++ b/files/ca/web/javascript/reference/global_objects/array/of/index.html @@ -0,0 +1,120 @@ +--- +title: Array.of() +slug: Web/JavaScript/Referencia/Objectes_globals/Array/of +translation_of: Web/JavaScript/Reference/Global_Objects/Array/of +--- +
{{JSRef}}
+ +

El mètode Array.of() crea una nova instància Array amb un nombre variable d'arguments, sense tenir en compte el nombre o el tipus d'arguments.

+ +

La diferència entre Array.of() i el constructor Array es troba en el maneig dels arguments sencers: Array.of(42) crea un array amb un sol element, 42, mentre que Array(42) crea un array amb 42 elements, Cadascun dels quals és undefined.

+ +

Sintaxi

+ +
Array.of(element0[, element1[, ...[, elementN]]])
+ +

Paràmetres

+ +
+
elementN
+
Elements a partir dels quals es crea l'array.
+
+ +

Descripció

+ +

Aquesta funció forma part del ECMAScript 6 estàndard. Per més informació vegeu proposta de l'Array.of i Array.from i Array.of polyfill.

+ +

Exemples

+ +
Array.of(1);         // [1]
+Array.of(1, 2, 3);   // [1, 2, 3]
+Array.of(undefined); // [undefined]
+
+ +

Polyfill

+ +

Executar el codi següent abans que cap altre codi crearà Array.of() en cas que no es trobi disponible de forma nativa.

+ +
if (!Array.of) {
+  Array.of = function() {
+    return Array.prototype.slice.call(arguments);
+  };
+}
+
+ +

Especificacions

+ + + + + + + + + + + + + + +
EspecificacióEstatComentaris
{{SpecName('ES6', '#sec-array.of', 'Array.of')}}{{Spec2('ES6')}}Definició inicial.
+ +

Compatibilitat amb navegadors

+ +
{{CompatibilityTable}}
+ +
+ + + + + + + + + + + + + + + + + + + +
CaracterísticaChromeFirefox (Gecko)Internet ExplorerOperaSafari
Suport bàsic{{CompatChrome(45)}}{{CompatGeckoDesktop("25")}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
CaracterísticaAndroidChrome per AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Suport bàsic{{CompatNo}}{{CompatChrome(39)}}{{CompatGeckoMobile("25")}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
+
+ +

Vegeu també

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