| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/No_variable_name | [Back] [Original] |
Get to know MDN better
The JavaScript exception "missing variable name" is a common error. It is usually caused by omitting a variable name or a typographic error.
SyntaxError: missing variable name (Firefox) SyntaxError: Unexpected token '='. Expected a parameter pattern or a ')' in parameter list. (Safari)
SyntaxError
A variable is missing a name. The cause is most likely a typo or a forgotten variable name.
Make sure that you've provided the name of the variable before the = sign.
When declaring multiple variables at the same time, make sure that the previous lines/declaration does not end with a comma instead of a semicolon.
const = "foo";
It is easy to forget to assign a name for your variable!
const description = "foo";
There are a few variable names that are reserved keywords. You can't use these. Sorry :(
const debugger = "whoop";
// SyntaxError: missing variable name
Pay special attention to commas when declaring multiple variables.
Is there an excess comma, or did you use commas instead of semicolons?
Did you remember to assign values for all your const variables?
let x, y = "foo",
const z, = "foo"
const first = document.getElementById("one"),
const second = document.getElementById("two"),
// SyntaxError: missing variable name
The fixed version:
let x,
y = "foo";
const z = "foo";
const first = document.getElementById("one");
const second = document.getElementById("two");
Array literals in JavaScript need square brackets around the values.
This won't work:
const arr = 1,2,3,4,5;
// SyntaxError: missing variable name
This would be correct:
const arr = [1, 2, 3, 4, 5];
This page was last modified on Jul 8, 2025 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 |