From 95aca4b4d8fa62815d4bd412fff1a364f842814a Mon Sep 17 00:00:00 2001 From: Ryan Johnson Date: Thu, 29 Apr 2021 16:16:42 -0700 Subject: remove retired locales (#699) --- .../reference/global_objects/array/fill/index.html | 174 --------------------- 1 file changed, 174 deletions(-) delete mode 100644 files/ca/web/javascript/reference/global_objects/array/fill/index.html (limited to 'files/ca/web/javascript/reference/global_objects/array/fill') diff --git a/files/ca/web/javascript/reference/global_objects/array/fill/index.html b/files/ca/web/javascript/reference/global_objects/array/fill/index.html deleted file mode 100644 index 67ad6677cf..0000000000 --- a/files/ca/web/javascript/reference/global_objects/array/fill/index.html +++ /dev/null @@ -1,174 +0,0 @@ ---- -title: Array.prototype.fill() -slug: Web/JavaScript/Reference/Global_Objects/Array/fill -translation_of: Web/JavaScript/Reference/Global_Objects/Array/fill -original_slug: Web/JavaScript/Referencia/Objectes_globals/Array/fill ---- -
{{JSRef}}
- -

El mètode fill() omple tots els elements d'un array a partir d'una posició inicial fins a una posició final amb un valor estàtic predeterminat.

- -

Sintaxi

- -
arr.fill(valor[, posInicial = 0[, posFinal = this.length]])
- -

Paràmetres

- -
-
valor
-
Valor amb el que s'omplirà l'array.
-
posInicial
-
Opcional. Posició inicial.
-
posFinal
-
Opcional. Posició final.
-
- -

Descripció

- -

L'interval d'elements a omplir és [posInicial, posFinal) (inici inclusiu, final exclusiu).

- -

El mètode fill accepta fins a tres arguments: valor, posInicialposFinal.

- -

Els arguments posInicial i posFinal són opcionals i si no s'especifiquen prenen per defecte els valors 0 i la propietat length de l'objecte this, respectivament.

- -

Si posInicial és negatiu, es considera com a length+start on length és la mida de l'array. Si posFinal és negatiu es considera com a length+end.

- -

La funció fill és genèrica intencionalment i no requereix que el valor this sigui un objecte de tipus Array.

- -

El mètode fill és mutable, ja que canviarà l'objecte this en si mateix i després el retornarà com a resultat, en comptes de retornar una copia d'aquest.

- -

Exemples

- -
[1, 2, 3].fill(4);               // [4, 4, 4]
-[1, 2, 3].fill(4, 1);            // [1, 4, 4]
-[1, 2, 3].fill(4, 1, 2);         // [1, 4, 3]
-[1, 2, 3].fill(4, 1, 1);         // [1, 2, 3]
-[1, 2, 3].fill(4, -3, -2);       // [4, 2, 3]
-[1, 2, 3].fill(4, NaN, NaN);     // [1, 2, 3]
-Array(3).fill(4);                // [4, 4, 4]
-[].fill.call({ length: 3 }, 4);  // {0: 4, 1: 4, 2: 4, length: 3}
-
- -

Polyfill

- -
if (!Array.prototype.fill) {
-  Array.prototype.fill = function(value) {
-
-    // Pasos 1-2.
-    if (this == null) {
-      throw new TypeError('this is null or not defined');
-    }
-
-    var O = Object(this);
-
-    // Pasos 3-5.
-    var len = O.length >>> 0;
-
-    // Pasos 6-7.
-    var start = arguments[1];
-    var relativeStart = start >> 0;
-
-    // Pasos 8.
-    var k = relativeStart < 0 ?
-      Math.max(len + relativeStart, 0) :
-      Math.min(relativeStart, len);
-
-    // Pasos 9-10.
-    var end = arguments[2];
-    var relativeEnd = end === undefined ?
-      len : end >> 0;
-
-    // Pasos 11.
-    var final = relativeEnd < 0 ?
-      Math.max(len + relativeEnd, 0) :
-      Math.min(relativeEnd, len);
-
-    // Pasos 12.
-    while (k < final) {
-      O[k] = value;
-      k++;
-    }
-
-    // Pasos 13.
-    return O;
-  };
-}
-
- -

Especificacions

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

Compatibilitat amb navegadors

- -
{{CompatibilityTable}}
- -
- - - - - - - - - - - - - - - - - - - -
CaracterísticaChromeFirefox (Gecko)Internet ExplorerOperaSafari
Suport bàsic{{CompatChrome("45")}} [1]{{CompatGeckoDesktop("31")}}{{CompatNo}}{{CompatNo}}{{CompatSafari("7.1")}}
-
- -
- - - - - - - - - - - - - - - - - - - - - -
CaracterísticaAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Suport bàsic{{CompatNo}}{{CompatNo}}{{CompatGeckoMobile("31")}}{{CompatNo}}{{CompatNo}}8.0
-
- -

[1] A partir del Chrome 36, està disponible a través d'una preferència. A chrome://flags, activeu l'entrada “Enable Experimental JavaScript”.

- -

Vegeu també

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