blob: 02cad6eb2f4fb48378c837442753fc0f6ca0e676 (
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:
- JavaScript
- SyntaxError
- errores
translation_of: Web/JavaScript/Reference/Errors/Unexpected_token
---
<div>{{jsSidebar("Errors")}}</div>
<h2 id="Mensaje">Mensaje</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 '=>' after argument list, got "x"
</pre>
<h2 id="Tipo_de_error">Tipo de error</h2>
<p>{{jsxref("SyntaxError")}}</p>
<h2 id="¿Que_significa_el_error">¿Que significa el error?</h2>
<p>Se esperaba un constructor específico de JavaScript pero se recibió algo diferente. Puede ser un simple error de tipeo.</p>
<h2 id="Ejemplos">Ejemplos</h2>
<h3 id="Se_espera_expresión">Se espera expresión</h3>
<p>Cuando se llama a una función, no se permiten comas al final de los argumentos. JavaScript espera un argumento que puede ser en realidad cualquier tipo de expresión.</p>
<pre class="brush: js example-bad">Math.max(2, 42,);
// SyntaxError: expected expression, got ')'
</pre>
<p>El error se corrije omitiendo la coma o agregando otro argumento:</p>
<pre class="brush: js example-good">Math.max(2, 42);
Math.max(2, 42, 13 + 37);
</pre>
<h2 id="See_also">See also</h2>
<ul>
<li>{{jsxref("Math.max()")}}</li>
</ul>
|