aboutsummaryrefslogtreecommitdiff
path: root/files/it/web/javascript/reference/errors/unexpected_token/index.html
blob: 17a9c78a4c2af292fe32eb1542a87809e8d2d296 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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>