I'm running JavaScript Lint on a project to check for common programming errors. I'm hitting this error:
SyntaxError: missing variable name
On this line:
var char, font;
From Googling, I've found that that error is shown when a reserved word is used as a variable name; but judging by MDN's list, neither char
nor font
is reserved.
What is the problem here?
If a reference to a local variable is accidentally misspelled, it will be interpreted as a reference to an implicitly declared global variable, which may indicate a bug. Even if this is intentional, it should be avoided as it makes the code hard to read.
Variable name may not start with a digit or underscore, and may not end with an underscore.
Never mind, I found the answer by reading What is the 'char' keyword used for?.
Apparently char
was reserved in ECMA 3, but removed as a reserved keyword in ECMA 5.
I've renamed my var
now, to prevent any potential issues arising with old implementations.
According to http://www.quackit.com/javascript/javascript_reserved_words.cfm
char
is a keyword reserved by JavaScript.
I think font
is fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With