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/it/web/javascript/reference/operators/conditional_operator | |
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/it/web/javascript/reference/operators/conditional_operator')
-rw-r--r-- | files/it/web/javascript/reference/operators/conditional_operator/index.html | 172 |
1 files changed, 0 insertions, 172 deletions
diff --git a/files/it/web/javascript/reference/operators/conditional_operator/index.html b/files/it/web/javascript/reference/operators/conditional_operator/index.html deleted file mode 100644 index 1d0bc7f79a..0000000000 --- a/files/it/web/javascript/reference/operators/conditional_operator/index.html +++ /dev/null @@ -1,172 +0,0 @@ ---- -title: Operatore condizionale (ternary) -slug: Web/JavaScript/Reference/Operators/Conditional_Operator -tags: - - JavaScript Operatore operatore -translation_of: Web/JavaScript/Reference/Operators/Conditional_Operator -original_slug: Web/JavaScript/Reference/Operators/Operator_Condizionale ---- -<p>L'<strong>operator</strong><strong>e</strong><strong> condizionale (ternary) </strong>è l'unico operatore JavaScript che necessità di tre operandi. Questo operatore è frequentemente usato al posto del comando <a href="/en-US/docs/Web/JavaScript/Reference/Statements/if...else"><code>if</code></a> per la sua sintassi concisa e perché fornisce direttamente un espressione valutabile.</p> - -<h2 id="Sintassi">Sintassi</h2> - -<pre class="syntaxbox"><em>condizione</em> ? <em>espressione1</em> : <em>espressione2</em> </pre> - -<h3 id="Parametri">Parametri</h3> - -<dl> - <dt><code>condizione</code></dt> - <dd>Un espressione booleana (che viene valutata in vero o <code>falso)</code>.</dd> -</dl> - -<dl> - <dt><code>espressione1</code>, <code>espressione2</code></dt> - <dd>Espressione di qualunque tipo (vedi avanti nella pagina).</dd> -</dl> - -<h2 id="Descrizione">Descrizione</h2> - -<p>Se <code>la condizione è vera</code>, l'operatore ritorna il valore di <code>espressione1</code>; altrimenti, ritorna il valore di <code>espressione2</code>. Per esempio, puoi usare questa espressione per mostrare un messaggio che cambia in base al valore della variabile <strong><code>isMember</code></strong>:</p> - -<pre class="brush: js">"The fee is " + (isMember ? "$2.00" : "$10.00") -</pre> - -<p>Puoi anche assegnare variabili dipendenti dal risultato di un operatore ternario:</p> - -<pre class="brush: js">var elvisLives = Math.PI > 4 ? "Yep" : "Nope";</pre> - -<p>Sono anche possibili espressioni con operatori ternari multipli (nota: l'operatore condizionale è associativo a destra):</p> - -<pre class="brush: js">var firstCheck = false, - secondCheck = false, - access = firstCheck ? "Access denied" : secondCheck ? "Access denied" : "Access granted"; - -console.log( access ); // logs "Access granted"</pre> - -<p>Puoi anche usare l'operatore ternario direttamente senza assegnamenti e senza combinazioni con altre espressioni, con lo scopo di valutare operazioni alternative:</p> - -<pre class="brush: js">var stop = false, age = 16; - -age > 18 ? location.assign("continue.html") : stop = true; -</pre> - -<p>Puoi anche valutare operazioni multiple separandole con delle virgole:</p> - -<pre class="brush: js">var stop = false, age = 23; - -age > 18 ? ( - alert("OK, you can go."), - location.assign("continue.html") -) : ( - stop = true, - alert("Sorry, you are much too young!") -); -</pre> - -<p>Puoi anche valutare più operazioni durante l'assegnamento di una variabile. In questo caso, <strong>l'ultimo valore separato da una virgola nelle parentesi sarà il valore assegnato</strong>.</p> - -<pre class="brush: js">var age = 16; - -var url = age > 18 ? ( - alert("OK, you can go."), - // alert returns "undefined", but it will be ignored because - // isn't the last comma-separated value of the parenthesis - "continue.html" // the value to be assigned if age > 18 -) : ( - alert("You are much too young!"), - alert("Sorry :-("), - // etc. etc. - "stop.html" // the value to be assigned if !(age > 18) -); - -location.assign(url); // "stop.html"</pre> - -<h2 id="Specifiche">Specifiche</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('ESDraft', '#sec-conditional-operator', 'Conditional Operator')}}</td> - <td>{{Spec2('ESDraft')}}</td> - <td> </td> - </tr> - <tr> - <td>{{SpecName('ES6', '#sec-conditional-operator', 'Conditional Operator')}}</td> - <td>{{Spec2('ES6')}}</td> - <td> </td> - </tr> - <tr> - <td>{{SpecName('ES5.1', '#sec-11.12', 'The conditional operator')}}</td> - <td>{{Spec2('ES5.1')}}</td> - <td> </td> - </tr> - <tr> - <td>{{SpecName('ES1', '#sec-11.12', 'The conditional operator')}}</td> - <td>{{Spec2('ES1')}}</td> - <td>Initial definition. Implemented in JavaScript 1.0.</td> - </tr> - </tbody> -</table> - -<h2 id="Compatibilità_con_Browser">Compatibilità con Browser</h2> - -<p>{{CompatibilityTable}}</p> - -<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>Opera</th> - <th>Safari</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - </tr> - </tbody> -</table> -</div> - -<div id="compat-mobile"> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</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>Basic support</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - </tr> - </tbody> -</table> -</div> - -<h2 id="Vedi_anche">Vedi anche</h2> - -<ul> - <li><a href="/en-US/docs/Web/JavaScript/Reference/Statements/if...else">if statement</a></li> -</ul> |