aboutsummaryrefslogtreecommitdiff
path: root/files/it/web/javascript/reference/global_objects/array/includes
diff options
context:
space:
mode:
Diffstat (limited to 'files/it/web/javascript/reference/global_objects/array/includes')
-rw-r--r--files/it/web/javascript/reference/global_objects/array/includes/index.html162
1 files changed, 162 insertions, 0 deletions
diff --git a/files/it/web/javascript/reference/global_objects/array/includes/index.html b/files/it/web/javascript/reference/global_objects/array/includes/index.html
new file mode 100644
index 0000000000..04dc817974
--- /dev/null
+++ b/files/it/web/javascript/reference/global_objects/array/includes/index.html
@@ -0,0 +1,162 @@
+---
+title: Array.prototype.includes()
+slug: Web/JavaScript/Reference/Global_Objects/Array/includes
+translation_of: Web/JavaScript/Reference/Global_Objects/Array/includes
+---
+<div>{{JSRef}}</div>
+
+<p>Il metodo <code><strong>includes()</strong></code> determina se un array include un certo elemento, ritornando <code>true</code> o <code>false</code> a seconda del caso</p>
+
+<h2 id="Sintassi">Sintassi</h2>
+
+<pre class="syntaxbox">var <var>boolean</var> = <var>array</var>.includes(<var>searchElement</var>[, <var>fromIndex</var>])</pre>
+
+<h3 id="Parametri">Parametri</h3>
+
+<dl>
+ <dt><code>searchElement</code></dt>
+ <dd>L'elemento da cercare.</dd>
+ <dt><code>fromIndex</code></dt>
+ <dd>Opzionale. La posizione nell'array da cui partire per cercare l'elemento <code>searchElement</code>. Un valore negativo ricerca dal valore di <code>array.length + fromIndex</code> in maniera ascendente. Il valore di default è 0.</dd>
+</dl>
+
+<h3 id="Valore_di_ritorno">Valore di ritorno</h3>
+
+<p>Un {{jsxref("Boolean")}}.</p>
+
+<h2 id="Examples">Examples</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';
+ if (this == null) {
+ throw new TypeError('Array.prototype.includes called on null or undefined');
+ }
+
+ var O = Object(this);
+ var len = parseInt(O.length, 10) || 0;
+ if (len === 0) {
+ return false;
+ }
+ var n = parseInt(arguments[1], 10) || 0;
+ var k;
+ if (n &gt;= 0) {
+ k = n;
+ } else {
+ k = len + n;
+ if (k &lt; 0) {k = 0;}
+ }
+ var currentElement;
+ while (k &lt; len) {
+ currentElement = O[k];
+ if (searchElement === currentElement ||
+ (searchElement !== searchElement &amp;&amp; currentElement !== currentElement)) { // NaN !== NaN
+ return true;
+ }
+ k++;
+ }
+ return false;
+ };
+}
+</pre>
+
+<h2 id="Specifications">Specifications</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES7', '#sec-array.prototype.includes', 'Array.prototype.includes')}}</td>
+ <td>{{Spec2('ES7')}}</td>
+ <td>Definizione iniziale.</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="Browser_compatibility">Browser compatibility</h2>
+
+<div>{{CompatibilityTable}}</div>
+
+<div id="compat-desktop">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Feature</th>
+ <th>Chrome</th>
+ <th>Firefox (Gecko)</th>
+ <th>Internet Explorer</th>
+ <th>Edge</th>
+ <th>Opera</th>
+ <th>Safari</th>
+ </tr>
+ <tr>
+ <td>Basic support</td>
+ <td>
+ <p>{{CompatChrome(47)}}</p>
+ </td>
+ <td>43</td>
+ <td>{{CompatNo}}</td>
+ <td>14279+</td>
+ <td>34</td>
+ <td>9</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<div id="compat-mobile">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Feature</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>Basic support</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="Vedi_anche">Vedi anche</h2>
+
+<ul>
+ <li>{{jsxref("TypedArray.prototype.includes()")}}</li>
+ <li>{{jsxref("String.prototype.includes()")}}</li>
+ <li>{{jsxref("Array.prototype.indexOf()")}}</li>
+</ul>