aboutsummaryrefslogtreecommitdiff
path: root/files/it/web/javascript/reference/errors
diff options
context:
space:
mode:
Diffstat (limited to 'files/it/web/javascript/reference/errors')
-rw-r--r--files/it/web/javascript/reference/errors/index.html31
-rw-r--r--files/it/web/javascript/reference/errors/invalid_array_length/index.html77
-rw-r--r--files/it/web/javascript/reference/errors/invalid_assignment_left-hand_side/index.html54
-rw-r--r--files/it/web/javascript/reference/errors/missing_semicolon_before_statement/index.html78
-rw-r--r--files/it/web/javascript/reference/errors/too_much_recursion/index.html72
-rw-r--r--files/it/web/javascript/reference/errors/unexpected_token/index.html50
-rw-r--r--files/it/web/javascript/reference/errors/unexpected_type/index.html67
7 files changed, 429 insertions, 0 deletions
diff --git a/files/it/web/javascript/reference/errors/index.html b/files/it/web/javascript/reference/errors/index.html
new file mode 100644
index 0000000000..c295fccea6
--- /dev/null
+++ b/files/it/web/javascript/reference/errors/index.html
@@ -0,0 +1,31 @@
+---
+title: JavaScript error reference
+slug: Web/JavaScript/Reference/Errors
+tags:
+ - Debugging
+ - Error
+ - Errors
+ - Exception
+ - JavaScript
+ - NeedsTranslation
+ - TopicStub
+ - exceptions
+translation_of: Web/JavaScript/Reference/Errors
+---
+<p>{{jsSidebar("Errors")}}</p>
+
+<p>Below, you'll find a list of errors which are thrown by JavaScript. These errors can be a helpful debugging aid, but the reported problem isn't always immediately clear. The pages below will provide additional details about these errors. Each error is an object based upon the {{jsxref("Error")}} object, and has a <code>name</code> and a <code>message</code>.</p>
+
+<p>Errors displayed in the Web console may include a link to the corresponding page below to help you quickly comprehend the problem in your code.</p>
+
+<h2 id="List_of_errors">List of errors</h2>
+
+<p>In this list, each page is listed by name (the type of error) and message (a more detailed human-readable error message). Together, these two properties provide a starting point toward understanding and resolving the error. For more information, follow the links below!</p>
+
+<p>{{ListSubPages("/en-US/docs/Web/JavaScript/Reference/Errors")}}</p>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li><a href="/en-US/docs/Learn/JavaScript/First_steps/What_went_wrong">What went wrong? Troubleshooting JavaScript</a>: Beginner's introductory tutorial on fixing JavaScript errors.</li>
+</ul>
diff --git a/files/it/web/javascript/reference/errors/invalid_array_length/index.html b/files/it/web/javascript/reference/errors/invalid_array_length/index.html
new file mode 100644
index 0000000000..61ee1cba5f
--- /dev/null
+++ b/files/it/web/javascript/reference/errors/invalid_array_length/index.html
@@ -0,0 +1,77 @@
+---
+title: 'RangeError: invalid array length'
+slug: Web/JavaScript/Reference/Errors/Invalid_array_length
+tags:
+ - Errori
+ - JavaScript
+ - RangeError
+translation_of: Web/JavaScript/Reference/Errors/Invalid_array_length
+---
+<div>{{jsSidebar("Errors")}}</div>
+
+<h2 id="Messaggio">Messaggio</h2>
+
+<pre class="syntaxbox">RangeError: invalid array length (Firefox)
+RangeError: Invalid array length (Chrome)
+RangeError: Invalid array buffer length (Chrome)
+</pre>
+
+<h2 id="Tipo_di_errore">Tipo di errore</h2>
+
+<p>{{jsxref("RangeError")}}</p>
+
+<h2 id="Cosa_è_andato_storto">Cosa è andato storto?</h2>
+
+<p>Un invalid array length può comparire in queste situazioni:</p>
+
+<ul>
+ <li>Quando viene creato un {{jsxref("Array")}} o un {{jsxref("ArrayBuffer")}}  che ha lunghezza negativa o maggiore uguale a  2<sup>32</sup>, oppure</li>
+ <li>quando viene impostata la proprietà {{jsxref("Array.length")}}  a un valore che è negativo o maggiore uguale a 2<sup>32</sup>.</li>
+</ul>
+
+<p>Perché la lunghezza di <code>Array</code> e <code>ArrayBuffer</code> è limitata? La proprietà <code>length</code> di un <code>Array </code>o di un <code>ArrayBuffer</code> è rappresentata da un intero di 32-bit  senza segno, che quindi permette di memorizzare valori nell'intervallo da 0 a 2<sup>32 </sup>- 1.</p>
+
+<p>Se stai creando un <code>Array</code> utilizzando il costruttore, potresti invece utilizzare la notazione letterale dove il primo argomento è interpretato come la lunghezza dell' <code>Array</code>.</p>
+
+<p>Altrimenti, potresti voler bloccare la lunghezza prima di settare la proprietà length, o utilizzarla come argomento del costruttore.</p>
+
+<h2 id="Esempi">Esempi</h2>
+
+<h3 id="Casi_non_validi">Casi non validi</h3>
+
+<pre class="brush: js example-bad">new Array(Math.pow(2, 40))
+new Array(-1)
+new ArrayBuffer(Math.pow(2, 32))
+new ArrayBuffer(-1)
+
+let a = [];
+a.length = a.length - 1; // setta -1 alla proprietà length
+
+let b = new Array(Math.pow(2, 32) - 1);
+b.length = b.length + 1; // setta 2^32 alla proprietà length
+</pre>
+
+<h3 id="Casi_validi">Casi validi</h3>
+
+<pre class="brush: js example-good">[ Math.pow(2, 40) ] // [ 1099511627776 ]
+[ -1 ] // [ -1 ]
+new ArrayBuffer(Math.pow(2, 32) - 1)
+new ArrayBuffer(0)
+
+let a = [];
+a.length = Math.max(0, a.length - 1);
+
+let b = new Array(Math.pow(2, 32) - 1);
+b.length = Math.min(0xffffffff, b.length + 1);
+
+// 0xffffffff è la notazione esadecimale di 2^32 - 1
+// che può essere riscritta come (-1 &gt;&gt;&gt; 0)
+</pre>
+
+<h2 id="Guarda_anche">Guarda anche</h2>
+
+<ul>
+ <li>{{jsxref("Array")}}</li>
+ <li>{{jsxref("Array.length")}}</li>
+ <li>{{jsxref("ArrayBuffer")}}</li>
+</ul>
diff --git a/files/it/web/javascript/reference/errors/invalid_assignment_left-hand_side/index.html b/files/it/web/javascript/reference/errors/invalid_assignment_left-hand_side/index.html
new file mode 100644
index 0000000000..d2412e48ce
--- /dev/null
+++ b/files/it/web/javascript/reference/errors/invalid_assignment_left-hand_side/index.html
@@ -0,0 +1,54 @@
+---
+title: 'ReferenceError: invalid assignment left-hand side'
+slug: Web/JavaScript/Reference/Errors/Invalid_assignment_left-hand_side
+tags:
+ - Errori
+ - JavaScript
+ - ReferenceError
+translation_of: Web/JavaScript/Reference/Errors/Invalid_assignment_left-hand_side
+---
+<div>{{jsSidebar("Errors")}}</div>
+
+<h2 id="Messaggio">Messaggio</h2>
+
+<pre class="syntaxbox">ReferenceError: invalid assignment left-hand side
+</pre>
+
+<h2 id="Tipo_di_errore">Tipo di errore</h2>
+
+<p>{{jsxref("ReferenceError")}}.</p>
+
+<h2 id="Che_cosa_è_andato_storto">Che cosa è andato storto?</h2>
+
+<p>C'è stato un assegnamento inaspettato da qualche parte. Ciò, ad esempio, potrebbe essere dovuto alla confusione tra  l' <a href="/en-US/docs/Web/JavaScript/Reference/Operators/Assignment_Operators">operatore d'assegnazione</a> e l' <a href="/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators">operatore di confronto</a>. Mentre un solo segno  di "<code>=</code>" assegna un valore ad una variabile, l'operatore "<code>==</code>" o "<code>===</code>" effettua il confronto tra valori.</p>
+
+<h2 id="Esempi">Esempi</h2>
+
+<pre class="brush: js example-bad">if (Math.PI = 3 || Math.PI = 4) {
+ console.log('niente!');
+}
+// ReferenceError: invalid assignment left-hand side
+
+var str = 'Ciao, '
++= 'sono io '
++= 'cosa stai cercando?';
+// ReferenceError: invalid assignment left-hand side
+</pre>
+
+<p>Nella dichiarazione <code>if</code>, puoi usare un operatore di confronto ("=="), e per la concatenazione di stringhe è necessario  l'operatore più ("+").</p>
+
+<pre class="brush: js example-good">if (Math.PI == 3 || Math.PI == 4) {
+ console.log('niente!');
+}
+
+var str = 'Ciao, '
++ 'dall/' '
++ 'altra parte!';
+</pre>
+
+<h2 id="Guarda_anche">Guarda anche</h2>
+
+<ul>
+ <li><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Assignment_Operators">Assegnamento degli operatori</a></li>
+ <li><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators">Operatori di comparazione</a></li>
+</ul>
diff --git a/files/it/web/javascript/reference/errors/missing_semicolon_before_statement/index.html b/files/it/web/javascript/reference/errors/missing_semicolon_before_statement/index.html
new file mode 100644
index 0000000000..c49646b4b1
--- /dev/null
+++ b/files/it/web/javascript/reference/errors/missing_semicolon_before_statement/index.html
@@ -0,0 +1,78 @@
+---
+title: 'SyntaxError: missing ; before statement'
+slug: Web/JavaScript/Reference/Errors/Missing_semicolon_before_statement
+tags:
+ - Errore di Sintassi
+ - Errori
+ - JavaScript
+ - Oggetti
+ - SyntaxError
+ - Variabili
+translation_of: Web/JavaScript/Reference/Errors/Missing_semicolon_before_statement
+---
+<div>{{jsSidebar("Errors")}}</div>
+
+<h2 id="Messaggio">Messaggio</h2>
+
+<pre class="syntaxbox">SyntaxError: Expected - Previsto ';' (Edge)
+SyntaxError: missing - Mancante; prima della dichiarazione (Firefox)
+</pre>
+
+<p> </p>
+
+<h2 id="Tipo_di_errore">Tipo di errore</h2>
+
+<p>{{jsxref("SyntaxError")}}.</p>
+
+<h2 id="Cosa_è_andato_storto">Cosa è andato storto?</h2>
+
+<p>C'è un punto e virgola (<code>;</code>) mancante. Le <a href="/en-US/docs/Web/JavaScript/Reference/Statements">dichiarazioni in JavaScript </a>devono essere determinate da il punto e virgola (<code>;</code>). Alcune di loro sono soggette all' <a href="/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#Automatic_semicolon_insertion">Inserzione Automatica a Semicolonne (ASI)</a>, ma in questo caso è necessario specificare la semicolonna, in modo che JavaScript legga correttamente il codice sorgente.</p>
+
+<p>In ogni caso, molto spesso, questo errore è solo una conseguenza di un altro, come lo scorretto uso degli apici, o l'uso errato di <code>var</code>. Potresti anche avere troppe parentesi da qualche parte. Ricontrolla la sintassi del codice quando appare questo errore.</p>
+
+<h2 id="Esempi">Esempi</h2>
+
+<h3 id="Stringhe_senza_escape_()">Stringhe senza escape (\)</h3>
+
+<p>Questo errore accade frequentemente quando si usa un apostrofo senza carattere di escape. Il motore di JavaScript si aspetta la fine di una stringa. Per esempio:</p>
+
+<pre class="brush: js example-bad">var foo = 'Tom's bar';
+// (') interrompe è atteso ("..'..") o ('..\'..')
+// SyntaxError: missing ; prima della dichiarazione</pre>
+
+<p>Per risolvere, usa le virgolette oppure un carattere di escape (backslash):</p>
+
+<pre class="brush: js example-good">var foo = "Tom's bar"; &lt;- in questo modo
+var foo = 'Tom\'s bar'; &lt;- in questo modo
+</pre>
+
+<p> </p>
+
+<h3 id="Dichiarare_le_proprietà_con_var">Dichiarare le proprietà con var</h3>
+
+<p><strong>Non </strong>puoi dichiarare le proprietà di un oggetto o di un array con una dichiarazione <code>var</code>.</p>
+
+<pre class="brush: js example-bad">var obj = {};
+var obj.foo = 'hi';
+// SyntaxError missing ; before statement
+
+var array = [];
+var array[0] = 'there';
+// SyntaxError missing ; before statement
+</pre>
+
+<p>Prova invece ad omettere la parola chiave <code>var</code>:</p>
+
+<pre class="brush: js example-good">var obj = {};
+obj.foo = 'hi';
+
+var array = [];
+array[0] = 'there';
+</pre>
+
+<h2 id="Controlla_anche">Controlla anche</h2>
+
+<ul>
+ <li><a href="/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#Automatic_semicolon_insertion">Inserzione Automatica a Semicolonna (ASI)</a></li>
+ <li><a href="/en-US/docs/Web/JavaScript/Reference/Statements">Dichiarazioni in JavaScript</a></li>
+</ul>
diff --git a/files/it/web/javascript/reference/errors/too_much_recursion/index.html b/files/it/web/javascript/reference/errors/too_much_recursion/index.html
new file mode 100644
index 0000000000..049ed04cf0
--- /dev/null
+++ b/files/it/web/javascript/reference/errors/too_much_recursion/index.html
@@ -0,0 +1,72 @@
+---
+title: 'InternalError: too much recursion'
+slug: Web/JavaScript/Reference/Errors/Too_much_recursion
+tags:
+ - Errore
+ - JavaScript
+translation_of: Web/JavaScript/Reference/Errors/Too_much_recursion
+---
+<div>{{jsSidebar("Errors")}}</div>
+
+<p>The JavaScript exception "too much recursion" or "Maximum call stack size exceeded" occurs when there are too many function calls, or a function is missing a base case.</p>
+
+<h2 id="Message">Message</h2>
+
+<pre class="syntaxbox notranslate">Error: Spazio nello stack esaurito (Edge)
+InternalError: Troppa ricorsione (Firefox)
+RangeError: Dimensioni massime dello stack superate (Chrome)
+</pre>
+
+<h2 id="Error_type">Error type</h2>
+
+<p>{{jsxref("InternalError")}}.</p>
+
+<h2 id="Cosè_andato_storto">Cos'è andato storto?</h2>
+
+<p>Una funzione che si chiama da sola si chiama <em>funzione ricorsiva</em>. Una volta che la condizione è soddisfatta, la funzione smette di chiamarsi. Questo si chiama <em>caso di base.</em></p>
+
+<p>In certi versi, la ricorsione è analoga ai cicli. Entrambi eseguono lo stesso codice più volte, ed entrambi richiedono una condizione(per evitare cicli infiniti,o in questo caso, ricorsioni infinite). Quando ci sono troppe chiamate, o manca il caso di base , JavaScript lancerà questo errore.</p>
+
+<h2 id="Esempi">Esempi</h2>
+
+<p>Questa funzione ricorsiva si chiama 10 volte, secondo le condizioni d'uscita</p>
+
+<pre class="brush: js notranslate">function ciclo(x) {
+ if (x &gt;= 10) // "x &gt;= 10" condizione d'uscita
+ return;
+ // do stuff
+ ciclo(x + 1); // chiamata ricorsiva
+}
+ciclo(0);</pre>
+
+<p>Impostare questa condizione a valori estremamente alti non funzionerà:</p>
+
+<pre class="brush: js example-bad notranslate">function ciclo(x) {
+ if (x &gt;= 1000000000000)
+ return;
+ // fà cose
+ ciclo(x + 1);
+}
+ciclo(0);
+
+// Errore Interno: troppa ricorsione</pre>
+
+<p>Alla funzione manca un caso base.Visto che non c'è condizione di uscita, la funzione chiama se stessa all'infinito.</p>
+
+<pre class="brush: js example-bad notranslate">function ciclo(x) {
+ // Manca caso base
+
+ciclo(x + 1); // Chiamata ricorsiva
+}
+
+ciclo(0);
+
+// Errore Interno: troppa ricorsione</pre>
+
+<h2 id="Vedi_anche">Vedi anche</h2>
+
+
+
+<ul>
+ <li>{{Glossary("Recursion")}}</li>
+</ul>
diff --git a/files/it/web/javascript/reference/errors/unexpected_token/index.html b/files/it/web/javascript/reference/errors/unexpected_token/index.html
new file mode 100644
index 0000000000..17a9c78a4c
--- /dev/null
+++ b/files/it/web/javascript/reference/errors/unexpected_token/index.html
@@ -0,0 +1,50 @@
+---
+title: 'SyntaxError: Unexpected token'
+slug: Web/JavaScript/Reference/Errors/Unexpected_token
+tags:
+ - Errori
+ - JavaScript
+ - Sintassi
+translation_of: Web/JavaScript/Reference/Errors/Unexpected_token
+---
+<div>{{jsSidebar("Errors")}}</div>
+
+<h2 id="Messaggio">Messaggio</h2>
+
+<pre class="syntaxbox">SyntaxError: espressione prevista, si ottiene "x"
+SyntaxError: nome proprietà previsto, si ottiene "x"
+SyntaxError: target previsto, si ottiene "x"
+SyntaxError: nome dell'argomento rest previsto, si ottiene "x"
+SyntaxError: parentesi di chiusura prevista, si ottiene "x"
+SyntaxError: previsto '=&gt;' dopo la lista degli argomenti, si ottiene "x"
+</pre>
+
+<h2 id="Tipo_di_errore">Tipo di errore</h2>
+
+<p>{{jsxref("SyntaxError")}}</p>
+
+<h2 id="Cosa_è_andato_storto">Cosa è andato storto?</h2>
+
+<p>Era atteso un costrutto specifico del linguaggio, ma è stato fornito qualcosa di diverso. Potrebbe trattarsi di un semplice errore di digitazione.</p>
+
+<h2 id="Esempi">Esempi</h2>
+
+<h3 id="Espressione_prevista">Espressione prevista</h3>
+
+<p>Ad esempio, non è permesso terminare una lista di argomenti con la virgola, in quanto JavaScript si aspetta un altro argomento.</p>
+
+<pre class="brush: js example-bad">Math.max(2, 42,);
+// SyntaxError: expected expression, got ')'
+</pre>
+
+<p>Sarebbe invece corretto omettere la virgola o specificare un altro argomento (che potrebbe anche essere un espressione):</p>
+
+<pre class="brush: js example-good">Math.max(2, 42);
+Math.max(2, 42, 13 + 37);
+</pre>
+
+<h2 id="Vedi_anche">Vedi anche</h2>
+
+<ul>
+ <li>{{jsxref("Math.max()")}}</li>
+</ul>
diff --git a/files/it/web/javascript/reference/errors/unexpected_type/index.html b/files/it/web/javascript/reference/errors/unexpected_type/index.html
new file mode 100644
index 0000000000..632b9bf756
--- /dev/null
+++ b/files/it/web/javascript/reference/errors/unexpected_type/index.html
@@ -0,0 +1,67 @@
+---
+title: 'TypeError: "x" is (not) "y"'
+slug: Web/JavaScript/Reference/Errors/Unexpected_type
+tags:
+ - Errori
+ - JavaScript
+ - TypeError
+translation_of: Web/JavaScript/Reference/Errors/Unexpected_type
+---
+<div>{{jsSidebar("Errors")}}</div>
+
+<h2 id="Messaggio">Messaggio</h2>
+
+<pre class="syntaxbox">TypeError: "x" is (not) "y"
+
+Examples:
+TypeError: "x" is undefined
+TypeError: "x" is null
+TypeError: "undefined" is not an object
+TypeError: "x" is not an object or null
+TypeError: "x" is not a symbol
+</pre>
+
+<h2 id="Tipo_di_errore">Tipo di errore</h2>
+
+<p>{{jsxref("TypeError")}}.</p>
+
+<h2 id="Cosa_è_andato_storto">Cosa è andato storto?</h2>
+
+<p>C'è stato un tipo inaspettato. Questo accade spesso con valori {{jsxref("undefined")}} o {{jsxref("null")}}.</p>
+
+<p>Inoltre, alcuni metodi, come {{jsxref("Object.create()")}} o {{jsxref("Symbol.keyFor()")}}, richiedono che sia fornito un tipo specifico.</p>
+
+<h2 id="Esempi">Esempi</h2>
+
+<h3 id="Casi_non_validi">Casi non validi</h3>
+
+<pre class="brush: js example-bad">// casi undefined e null in cui il metodo substring non funzionerà
+var foo = undefined;
+foo.substring(1); // TypeError: foo non è definita
+
+var foo = null;
+foo.substring(1); // TypeError: foo è null
+
+
+// Alcuni metodi potrebbero richiedere un tipo specifico
+var foo = {}
+Symbol.keyFor(foo); // TypeError: foo non è un simbolo
+
+var foo = 'bar'
+Object.create(foo); // TypeError: "foo" non è un oggetto o è null
+</pre>
+
+<h3 id="Risolvere_il_problema">Risolvere il problema</h3>
+
+<p>Per risolvere il problema di valori <code>undefined</code> o <code>null</code>, si può usare l'operatore <a href="/en-US/docs/Web/JavaScript/Reference/Operators/typeof">typeof</a> operator, ad esempio.</p>
+
+<pre class="brush: js">if (typeof foo !== 'undefined') {
+ // Ora sappiamo che foo è definita, possiamo procedere.
+}</pre>
+
+<h2 id="Vedi_anche">Vedi anche</h2>
+
+<ul>
+ <li>{{jsxref("undefined")}}</li>
+ <li>{{jsxref("null")}}</li>
+</ul>