diff options
| author | Florian Merz <me@fiji-flo.de> | 2021-02-11 14:47:54 +0100 |
|---|---|---|
| committer | Florian Merz <me@fiji-flo.de> | 2021-02-11 14:47:54 +0100 |
| commit | 30feb96f6084a2fb976a24ac01c1f4a054611b62 (patch) | |
| tree | d73194ae27b60156ff0ca54013c8c4ad8519f10a /files/it/web/javascript/reference/classes/costruttore | |
| parent | 8260a606c143e6b55a467edf017a56bdcd6cba7e (diff) | |
| download | translated-content-30feb96f6084a2fb976a24ac01c1f4a054611b62.tar.gz translated-content-30feb96f6084a2fb976a24ac01c1f4a054611b62.tar.bz2 translated-content-30feb96f6084a2fb976a24ac01c1f4a054611b62.zip | |
unslug it: move
Diffstat (limited to 'files/it/web/javascript/reference/classes/costruttore')
| -rw-r--r-- | files/it/web/javascript/reference/classes/costruttore/index.html | 161 |
1 files changed, 0 insertions, 161 deletions
diff --git a/files/it/web/javascript/reference/classes/costruttore/index.html b/files/it/web/javascript/reference/classes/costruttore/index.html deleted file mode 100644 index afc6c44526..0000000000 --- a/files/it/web/javascript/reference/classes/costruttore/index.html +++ /dev/null @@ -1,161 +0,0 @@ ---- -title: costruttore -slug: Web/JavaScript/Reference/Classes/costruttore -translation_of: Web/JavaScript/Reference/Classes/constructor ---- -<div>{{jsSidebar("Classes")}}</div> - -<p>Il metodo <code>constructor</code> è un metodo speciale usato per la creazione e l'inizializzazione di un oggetto creato da una <code>classe</code>.</p> - -<h2 id="Sintassi">Sintassi</h2> - -<pre class="syntaxbox">constructor([argomenti]) { ... }</pre> - -<h2 id="Descrizione">Descrizione</h2> - -<p>In una classe ci può essere un solo metodo con il nome "constructor". Se una classe contiene una o più occorrenze del metodo <code>constructor</code> viene sollevato un errore di tipo {{jsxref("SyntaxError")}}. </p> - -<p>Un costruttore può usare la keyword <code>super</code> per chiamare il costruttore di una classe genitore.</p> - -<p>Se non viene specificato un metodo <code>constructor</code>, verrà usato quello di default.</p> - -<h2 id="Esempi">Esempi</h2> - -<h3 id="Usare_il_metodo_constructor">Usare il metodo <code>constructor</code></h3> - -<p>Questo pezzo di codice è stato preso da <a href="https://github.com/GoogleChrome/samples/blob/gh-pages/classes-es6/index.html">classes sample</a> (<a href="https://googlechrome.github.io/samples/classes-es6/index.html">live demo</a>).</p> - -<pre class="brush: js">class Square extends Polygon { - constructor(length) { - // Chiama il costruttore della classe padre usando lo stesso valore length - // come altezza e come larghezza del Poligono - super(length, length); - // Nota: Nelle classi derivate, super() deve essere chiamato prima - // dell'utilizzo di 'this', altrimenti viene sollevato un reference error. - this.name = 'Square'; - } - - get area() { - return this.height * this.width; - } - - set area(value) { - this.area = value; - } -}</pre> - -<h3 id="Costruttori_predefinito">Costruttori predefinito</h3> - -<p>Se non viene specificato un metodo costruttore, verrà usato quello di default. Per le classi base il costruttore di default è:</p> - -<pre class="brush: js">constructor() {} -</pre> - -<p>Per le classi derivate invece è:</p> - -<pre class="brush: js">constructor(...args) { - super(...args); -}</pre> - -<h2 id="Specifiche">Specifiche</h2> - -<table class="standard-table"> - <tbody> - <tr> - <th scope="col">Specifica</th> - <th scope="col">Stato</th> - <th scope="col">Commento</th> - </tr> - <tr> - <td>{{SpecName('ES6', '#sec-static-semantics-constructormethod', 'Constructor Method')}}</td> - <td>{{Spec2('ES6')}}</td> - <td>Initial definition.</td> - </tr> - <tr> - <td>{{SpecName('ESDraft', '#sec-static-semantics-constructormethod', 'Constructor Method')}}</td> - <td>{{Spec2('ESDraft')}}</td> - <td> </td> - </tr> - </tbody> -</table> - -<h2 id="Compatibilità_con_i_Browser">Compatibilità con i Browser</h2> - -<p>{{CompatibilityTable}}</p> - -<div id="compat-desktop"> -<table class="compat-table"> - <tbody> - <tr> - <th>Specifica</th> - <th>Chrome</th> - <th>Firefox (Gecko)</th> - <th>Internet Explorer</th> - <th>Opera</th> - <th>Safari</th> - </tr> - <tr> - <td>Supporto Base</td> - <td>{{CompatChrome(42.0)}}</td> - <td>{{CompatGeckoDesktop(45)}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - </tr> - <tr> - <td>Costruttore predefinito</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatGeckoDesktop(45)}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - </tr> - </tbody> -</table> -</div> - -<div id="compat-mobile"> -<table class="compat-table"> - <tbody> - <tr> - <th>Specifica</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 per Android</th> - </tr> - <tr> - <td>Supporto Base</td> - <td>{{CompatNo}}</td> - <td>{{CompatChrome(42.0)}}</td> - <td>{{CompatGeckoMobile(45)}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatChrome(42.0)}}</td> - </tr> - <tr> - <td>Costruttore predefinito</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatGeckoMobile(45)}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - </tr> - </tbody> -</table> -</div> - -<h2 id="Vedi_anche">Vedi anche</h2> - -<ul> - <li><a href="/en-US/docs/Web/JavaScript/Reference/Operators/super">super()</a></li> - <li><a href="/en-US/docs/Web/JavaScript/Reference/Operators/class"><code>class</code> expression</a></li> - <li><a href="/en-US/docs/Web/JavaScript/Reference/Statements/class"><code>class</code> declaration</a></li> - <li><a href="/en-US/docs/Web/JavaScript/Reference/Classes">Classes</a></li> -</ul> |
