diff options
Diffstat (limited to 'files/ca/web/javascript/reference/global_objects/array/includes')
-rw-r--r-- | files/ca/web/javascript/reference/global_objects/array/includes/index.html | 159 |
1 files changed, 0 insertions, 159 deletions
diff --git a/files/ca/web/javascript/reference/global_objects/array/includes/index.html b/files/ca/web/javascript/reference/global_objects/array/includes/index.html deleted file mode 100644 index b788348abb..0000000000 --- a/files/ca/web/javascript/reference/global_objects/array/includes/index.html +++ /dev/null @@ -1,159 +0,0 @@ ---- -title: Array.prototype.includes() -slug: Web/JavaScript/Reference/Global_Objects/Array/includes -translation_of: Web/JavaScript/Reference/Global_Objects/Array/includes -original_slug: Web/JavaScript/Referencia/Objectes_globals/Array/includes ---- -<div>{{JSRef}}</div> - -<p>El mètode <code><strong>includes()</strong></code> determina si un array inclou un element concret, retornant <code>true</code> o <code>false</code> segons s'escaigui. </p> - -<h2 id="Sintaxi">Sintaxi</h2> - -<pre class="syntaxbox">var <var>boolean</var> = <var>array</var>.includes(elementCercat[, desdePosicio])</pre> - -<h3 id="Parameters">Parameters</h3> - -<dl> - <dt>elementCercat</dt> - <dd>L'element a cercar.</dd> - <dt>desdePosicio</dt> - <dd>Opcional. La posició de l'array a partir de la qual començar la cerca de <code>elementCercat</code>. Un valor negatiu cercarà el nombre absolut donat de posicions contant des del final de l'array. El seu valor per defecte és 0.</dd> -</dl> - -<h3 id="Valor_retornat">Valor retornat</h3> - -<p>Un {{jsxref("Boolean")}}.</p> - -<h2 id="Exemples">Exemples</h2> - -<pre class="brush: js">[1, 2, 3].includes(2); // true -[1, 2, 3].includes(4); // false -[1, 2, 3].includes(3, 3); // false -[1, 2, 3].includes(3, -1); // true -[1, 2, NaN].includes(NaN); // true -</pre> - -<h2 id="Polyfill">Polyfill</h2> - -<pre class="brush: js">if (!Array.prototype.includes) { - Array.prototype.includes = function(searchElement /*, fromIndex*/ ) { - 'use strict'; - var O = Object(this); - var len = parseInt(O.length) || 0; - if (len === 0) { - return false; - } - var n = parseInt(arguments[1]) || 0; - var k; - if (n >= 0) { - k = n; - } else { - k = len + n; - if (k < 0) {k = 0;} - } - var currentElement; - while (k < len) { - currentElement = O[k]; - if (searchElement === currentElement || - (searchElement !== searchElement && currentElement !== currentElement)) { // NaN !== NaN - return true; - } - k++; - } - return false; - }; -} -</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('ES7', '#sec-array.prototype.includes', 'Array.prototype.includes')}}</td> - <td>{{Spec2('ES7')}}</td> - <td>Definició inicial.</td> - </tr> - <tr> - <td>{{SpecName('ESDraft', '#sec-array.prototype.includes', 'Array.prototype.includes')}}</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>Edge</th> - <th>Opera</th> - <th>Safari</th> - </tr> - <tr> - <td>Suport bàsic</td> - <td> - <p>{{CompatChrome(47)}}</p> - </td> - <td>43</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>34</td> - <td>9</td> - </tr> - </tbody> -</table> -</div> - -<div id="compat-mobile"> -<table class="compat-table"> - <tbody> - <tr> - <th>Característica</th> - <th>Android</th> - <th>Android Webview</th> - <th>Firefox Mobile (Gecko)</th> - <th>IE Mobile</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - <th>Chrome for Android</th> - </tr> - <tr> - <td>Suport bàsic</td> - <td>{{CompatNo}}</td> - <td> - <p>{{CompatChrome(47)}}</p> - </td> - <td>43</td> - <td>{{CompatNo}}</td> - <td>34</td> - <td>9</td> - <td> - <p>{{CompatChrome(47)}}</p> - </td> - </tr> - </tbody> -</table> -</div> - -<h2 id="Vegeu_també">Vegeu també</h2> - -<ul> - <li>{{jsxref("TypedArray.prototype.includes()")}}</li> - <li>{{jsxref("String.prototype.includes()")}}</li> - <li>{{jsxref("Array.prototype.indexOf()")}}</li> -</ul> |