| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/es/docs/Web/JavaScript/Reference/Errors/No_variable_name | [Back] [Original] |
Get to know MDN better
Esta pgina ha sido traducida del ingls por la comunidad. Aprende ms y nete a la comunidad de MDN Web Docs.
SyntaxError: missing variable name (Firefox) SyntaxError: Unexpected token = (Chrome)
SyntaxError
Una variable no tiene nombre. Esto es un error recurrente en el cdigo. Probablemente una coma est mal colocada en algn lugar o nombraste mal una variable. Completamente entendible. Nombrar cosas es difcil.
var = "foo";
Es bueno nombrar buenas variables. Todos hemos estado as.
var ohGodWhy = "foo";
Hay algunas palabras que son reservadas. No puedes usarlas para nombrar variables, lo siento :(
var debugger = "whoop";
// SyntaxError: missing variable name
Toma especial atencin a las comas cuando declaras multiples variables. Hay un exceso de comas? Accidentalmente aadiste comas en vez de punto y coma?
var x, y = "foo",
var x, = "foo"
var first = document.getElementById('one'),
var second = document.getElementById('two'),
// SyntaxError: missing variable name
La versin arreglada:
var x,
y = "foo";
var x = "foo";
var first = document.getElementById("one");
var second = document.getElementById("two");
Array literales en JavaScript necesitan corchetes alrededor de los valores. Esto no funciona:
var arr = 1, 2, 3, 4, 5;
// SyntaxError: missing variable name
Esto es correcto:
var arr = [1, 2, 3, 4, 5];
This page was last modified on 17 dic 2024 by MDN contributors.
Your blueprint for a better internet.
Portions of this content are 19982026 by individual mozilla.org contributors. Content available under a Creative Commons license.
| Web Proxy Viewer | New URL | Original Page |