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.
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.
It is easy to forget to assign a name for your variable!
There are a few variable names that are reserved keywords. You can't use these. Sorry :(
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?
The fixed version:
Array literals in JavaScript need square brackets around the values. This won't work:
This would be correct:
This page was last modified on Jul 8, 2025 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.