aboutsummaryrefslogtreecommitdiff
path: root/files/ca/web/javascript/reference/global_objects/array/findindex
diff options
context:
space:
mode:
authorRyan Johnson <rjohnson@mozilla.com>2021-04-29 16:16:42 -0700
committerGitHub <noreply@github.com>2021-04-29 16:16:42 -0700
commit95aca4b4d8fa62815d4bd412fff1a364f842814a (patch)
tree5e57661720fe9058d5c7db637e764800b50f9060 /files/ca/web/javascript/reference/global_objects/array/findindex
parentee3b1c87e3c8e72ca130943eed260ad642246581 (diff)
downloadtranslated-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/findindex')
-rw-r--r--files/ca/web/javascript/reference/global_objects/array/findindex/index.html174
1 files changed, 0 insertions, 174 deletions
diff --git a/files/ca/web/javascript/reference/global_objects/array/findindex/index.html b/files/ca/web/javascript/reference/global_objects/array/findindex/index.html
deleted file mode 100644
index 4fdca8cbbf..0000000000
--- a/files/ca/web/javascript/reference/global_objects/array/findindex/index.html
+++ /dev/null
@@ -1,174 +0,0 @@
----
-title: Array.prototype.findIndex()
-slug: Web/JavaScript/Reference/Global_Objects/Array/findIndex
-translation_of: Web/JavaScript/Reference/Global_Objects/Array/findIndex
-original_slug: Web/JavaScript/Referencia/Objectes_globals/Array/findIndex
----
-<div>{{JSRef}}</div>
-
-<p>El mètode <code><strong>findIndex()</strong></code> retorna una <strong>posició</strong> de l'array si un element de l'array satisfà la funció de testeig donada. En cas contrari retornarà -1.</p>
-
-<p>Vegeu també el mètode {{jsxref("Array.find", "find()")}}, que retorna el <strong>valor</strong> trobat dins l'array en comptes de la posició.</p>
-
-<h2 id="Sintaxi">Sintaxi</h2>
-
-<pre class="syntaxbox"><code><var>arr</var>.findIndex(<var>callback</var>[, <var>thisArg</var>])</code></pre>
-
-<h3 id="Parameters">Parameters</h3>
-
-<dl>
- <dt><code>callback</code></dt>
- <dd>Funció que s'executarà per a cada valor de l'array, rep tres arguments:
- <dl>
- <dt><code>element</code></dt>
- <dd>L'element de l'array que s'està processant actualment.</dd>
- <dt><code>posició</code></dt>
- <dd>La posició de l'array que s'està processant actualment.</dd>
- <dt><code>array</code></dt>
- <dd>L'array des del qual s'ha cridat el mètode <code>find</code>.</dd>
- </dl>
- </dd>
- <dt><code>thisArg</code></dt>
- <dd>Opcional. L'objecte a utilitzar com a <code>this</code> mentre s'executi <code>callback</code>.</dd>
-</dl>
-
-<h2 id="Descripció">Descripció</h2>
-
-<p>El mètode <code>findIndex</code> executa la funció <code>callback</code> un cop per a cada element present a l'array fins que trobi un on <code>callback</code> retorni <code>true</code>. Si es troba aquest element el mètode <code>findIndex</code> retorna la posició de l'element trobat immediatament. En cas contrari <code>findIndex</code> retornarà -1. <code>callback</code> només serà invocada per a posicions de l'array que tinguin valors assignats; no serà invoada per a posicions que s'hagin eliminat o que mai hagin tingut assignat un valor.</p>
-
-<p>La invocaicó de <code>callback</code> té tres arguments: el valor de l'element, la posició de l'element i l'objecte array que està sent recorregut.</p>
-
-<p>Si es proporciona el paràmetre <code>thisArg</code> al cridar el mètode <code>findIndex</code>, aquest serà utilitzat com a <code>this</code> per a cada invocació del mètode <code>callback</code>. En cas de no ser proporcionat s'utilitzarà {{jsxref("undefined")}}.</p>
-
-<p><code>findIndex</code> no mutarà l'array des del que es crida.</p>
-
-<p>El rang d'elemnets que <code>findIndex</code> processarà es determina abans de la primera invocació a <code>callback</code>. Els elements afegits a l'array després de la crida a <code>findIndex</code> no seran visitats per <code>callback</code>. Si un element existent, no visitat encara, rep un altre valor, el valor percebut per <code>callback</code> serà aquell que tingui l'element al ser visitat; els elements visitats no són visitats.</p>
-
-<h2 id="Exemples">Exemples</h2>
-
-<h3 id="Trobar_la_posició_d'un_nombre_primer_dins_un_array">Trobar la posició d'un nombre primer dins un array</h3>
-
-<p>L'exemple següent trobarà la posició d'un element de l'array que sigui un nombre primer (o bé retornarà -1 si no n'hi ha cap).</p>
-
-<pre class="brush: js">function isPrime(element, index, array) {
- var start = 2;
- while (start &lt;= Math.sqrt(element)) {
- if (element % start++ &lt; 1) {
- return false;
- }
- }
- return element &gt; 1;
-}
-
-console.log([4, 6, 8, 12].findIndex(isPrime)); // -1, not found
-console.log([4, 6, 7, 12].findIndex(isPrime)); // 2
-</pre>
-
-<h2 id="Polyfill">Polyfill</h2>
-
-<p>Aquest mètode es va afegir a la especificació 6 de l'ECMAScript i pot no estar disponible encara en algunes implementacions de JavaScript. Tot i així es pot utilitzar el codi següent per a utilitzar-lo en entorns on no estigui disponible:</p>
-
-<pre class="brush: js">if (!Array.prototype.findIndex) {
- Array.prototype.findIndex = function(predicate) {
- if (this === null) {
- throw new TypeError('Array.prototype.findIndex called on null or undefined');
- }
- if (typeof predicate !== 'function') {
- throw new TypeError('predicate must be a function');
- }
- var list = Object(this);
- var length = list.length &gt;&gt;&gt; 0;
- var thisArg = arguments[1];
- var value;
-
- for (var i = 0; i &lt; length; i++) {
- value = list[i];
- if (predicate.call(thisArg, value, i, list)) {
- return i;
- }
- }
- return -1;
- };
-}
-</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.findIndex', 'Array.prototype.findIndex')}}</td>
- <td>{{Spec2('ES6')}}</td>
- <td>Definició inicial.</td>
- </tr>
- <tr>
- <td>{{SpecName('ESDraft', '#sec-array.prototype.findIndex', 'Array.prototype.findIndex')}}</td>
- <td>{{Spec2('ESDraft')}}</td>
- <td> </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.0)}}</td>
- <td>{{CompatGeckoDesktop("25.0")}}</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("25.0")}}</td>
- <td>{{CompatNo}}</td>
- <td>{{CompatNo}}</td>
- <td>8.0</td>
- </tr>
- </tbody>
-</table>
-</div>
-
-<h2 id="Vegeu_també">Vegeu també</h2>
-
-<ul>
- <li>{{jsxref("Array.prototype.find()")}}</li>
- <li>{{jsxref("Array.prototype.indexOf()")}}</li>
-</ul>