SyntaxError: missing variable name
SyntaxError: missing variable name (Firefox) SyntaxError: Unexpected token = (Chrome)
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
When declaring multiple variables at the same time, make sure that the previous lines/declaration does not end with a comma instead of a semi-colon.
var = "foo";
Coming up with a descriptive variable name is challenging for most developers. It gets easier over time.
var description = "foo";
There are a few variable names that are reserved keywords. You can't use these. Sorry :(
var debugger = "whoop"; // SyntaxError: missing variable name
Pay special attention to commas when declaring multiple variables. Is there an excess comma? Did you accidentally add commas instead of semicolons?
var x, y = "foo", var x, = "foo" var first = document.getElementById('one'), var second = document.getElementById('two'), // SyntaxError: missing variable name
The fixed version:
var x, y = "foo"; var x = "foo"; var first = document.getElementById('one'); var second = document.getElementById('two');
var arr = 1,2,3,4,5; // SyntaxError: missing variable name
This would be correct:
var arr = [1,2,3,4,5];