aboutsummaryrefslogtreecommitdiff
path: root/files/pt-br/web/javascript/reference/errors/unexpected_token/index.html
blob: 7455321080a1ff546aa9da0054456c96b62e6266 (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
51
---
title: 'SyntaxError: Unexpected token'
slug: Web/JavaScript/Reference/Errors/Unexpected_token
tags:
  - Erro de Sintaxe
  - Erros
  - JavaScript
  - SyntaxError
translation_of: Web/JavaScript/Reference/Errors/Unexpected_token
---
<div>{{jsSidebar("Errors")}}</div>

<h2 id="Mensagem">Mensagem</h2>

<pre class="syntaxbox">SyntaxError: expected expression, got "x"
SyntaxError: expected property name, got "x"
SyntaxError: expected target, got "x"
SyntaxError: expected rest argument name, got "x"
SyntaxError: expected closing parenthesis, got "x"
SyntaxError: expected '=&gt;' after argument list, got "x"
</pre>

<h2 id="Tipo_de_erro">Tipo de erro</h2>

<p>{{jsxref("SyntaxError")}}</p>

<h2 id="O_que_deu_errado">O que deu errado?</h2>

<p>Uma construção específica da linguagem era esperada, mas algo não foi fornecido. Isto deve ser um simples erro de digitação.</p>

<h2 id="Exemplos">Exemplos</h2>

<h3 id="Expressão_esperada">Expressão esperada</h3>

<p>Por exemplo, quando funções são chamadas, vírgulas sem um valor na sequência não são permitidas. O JavaScript esperarará outro argumento, como pode ser qualquer expressão.</p>

<pre class="brush: js example-bad">Math.max(2, 42,);
// SyntaxError: expected expression, got ')'
</pre>

<p>O correto é omitir a vírgula ou adicionar outro argumento:</p>

<pre class="brush: js example-good">Math.max(2, 42);
Math.max(2, 42, 13 + 37);
</pre>

<h2 id="Veja_também">Veja também</h2>

<ul>
 <li>{{jsxref("Math.max()")}}</li>
</ul>