diff options
author | Ryan Johnson <rjohnson@mozilla.com> | 2021-04-29 16:16:42 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-29 16:16:42 -0700 |
commit | 95aca4b4d8fa62815d4bd412fff1a364f842814a (patch) | |
tree | 5e57661720fe9058d5c7db637e764800b50f9060 /files/ca/web/javascript/reference/global_objects/array/fill/index.html | |
parent | ee3b1c87e3c8e72ca130943eed260ad642246581 (diff) | |
download | translated-content-95aca4b4d8fa62815d4bd412fff1a364f842814a.tar.gz translated-content-95aca4b4d8fa62815d4bd412fff1a364f842814a.tar.bz2 translated-content-95aca4b4d8fa62815d4bd412fff1a364f842814a.zip |
remove retired locales (#699)
Diffstat (limited to 'files/ca/web/javascript/reference/global_objects/array/fill/index.html')
-rw-r--r-- | files/ca/web/javascript/reference/global_objects/array/fill/index.html | 174 |
1 files changed, 0 insertions, 174 deletions
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 ---- -<div>{{JSRef}}</div> - -<p>El mètode <code><strong>fill()</strong></code> omple tots els elements d'un array a partir d'una posició inicial fins a una posició final amb un valor estàtic predeterminat.</p> - -<h2 id="Sintaxi">Sintaxi</h2> - -<pre class="syntaxbox"><code><var>arr</var>.fill(valor[, <var>posInicial <var>= 0[, posFinal = this.length]])</var></var></code></pre> - -<h3 id="Paràmetres">Paràmetres</h3> - -<dl> - <dt><code>valor</code></dt> - <dd>Valor amb el que s'omplirà l'array.</dd> - <dt><code>posInicial</code></dt> - <dd>Opcional. Posició inicial.</dd> - <dt><code>posFinal</code></dt> - <dd>Opcional. Posició final.</dd> -</dl> - -<h2 id="Descripció">Descripció</h2> - -<p>L'interval d'elements a omplir és <code>[posInicial, posFinal)</code> (inici inclusiu, final exclusiu).</p> - -<p>El mètode <strong><code>fill</code></strong> accepta fins a tres arguments: <code>valor</code>, <code>posInicial</code> i <code>posFinal.</code></p> - -<p>Els arguments <code>posInicial</code> i <code>posFinal</code> són opcionals i si no s'especifiquen prenen per defecte els valors <code>0</code> i la propietat <code>length</code> de l'objecte <code>this</code>, respectivament.</p> - -<p>Si <code>posInicial</code> és negatiu, es considera com a <code>length+start</code> on <code>length</code> és la mida de l'array. Si <code>posFinal</code> és negatiu es considera com a <code>length+end</code>.</p> - -<p>La funció <strong>fill</strong> és genèrica intencionalment i no requereix que el valor <code>this</code> sigui un objecte de tipus <code>Array</code>.</p> - -<p>El mètode <strong>fill</strong> és mutable, ja que canviarà l'objecte <code>this</code> en si mateix i després el retornarà com a resultat, en comptes de retornar una copia d'aquest.</p> - -<h2 id="Exemples">Exemples</h2> - -<pre class="brush: js">[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} -</pre> - -<h2 id="Polyfill">Polyfill</h2> - -<pre class="brush: js">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; - }; -} -</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-array.prototype.fill', 'Array.prototype.fill')}}</td> - <td>{{Spec2('ES6')}}</td> - <td>Definició inicial.</td> - </tr> - </tbody> -</table> - -<h2 id="Compatibilitat_amb_navegadors">Compatibilitat amb navegadors</h2> - -<div>{{CompatibilityTable}}</div> - -<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("45")}} [1]</td> - <td>{{CompatGeckoDesktop("31")}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatSafari("7.1")}}</td> - </tr> - </tbody> -</table> -</div> - -<div id="compat-mobile"> -<table class="compat-table"> - <tbody> - <tr> - <th>Característica</th> - <th>Android</th> - <th>Chrome for 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>{{CompatNo}}</td> - <td>{{CompatGeckoMobile("31")}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>8.0</td> - </tr> - </tbody> -</table> -</div> - -<p>[1] A partir del Chrome 36, està disponible a través d'una preferència. A chrome://flags, activeu l'entrada “Enable Experimental JavaScript”.</p> - -<h2 id="Vegeu_també">Vegeu també</h2> - -<ul> - <li>{{jsxref("Array")}}</li> - <li>{{jsxref("TypedArray.prototype.fill()")}}</li> -</ul> |