enum ButtonType { Autowoot, Autoqueue }
Is causing Google Chrome's developer tools to give me this error:
Uncaught SyntaxError: <unknown message reserved_word>
I read that you can create enumerations like that from here, but my script doesn't run because of this error here. I'm doing exactly what that person who answered the question wrote, and it doesn't function. Any ideas?
Thanks!
enum ButtonType { Autowoot, Autoqueue }
Is causing Google Chrome's developer tools to give me this error:
Uncaught SyntaxError: <unknown message reserved_word>
I read that you can create enumerations like that from here, but my script doesn't run because of this error here. I'm doing exactly what that person who answered the question wrote, and it doesn't function. Any ideas?
Thanks!
Share Improve this question asked Jun 20, 2012 at 12:38 user1436713user1436713 852 silver badges6 bronze badges2 Answers
Reset to default 3You need to do something like:
var ButtonType = {
'Autowoot' : 0,
'Autoqueue' : 1
};
The enum syntax enum ButtonType { Autowoot, Autoqueue }
is not supported currently.
JavaScript doesn't do static typing of variables.
Once a variable has been declared, it's data may be anything that's a valid JavaScript construct. (Well, really, everything is pretty much an object).
enum ButtonType = {'Autowoot':0, 'Autoqueue':1};
Is giving an error because enum
is a javascript reserved word marked for future usage. You can't use it, but it does nothing.
If you're trying to declare an object called ButtonType
in the current execution scope, you should do as @xdazz said:
var ButtonType = {'Autowoot':0, 'Autoqueue':1};
(If you want it in another scope, that's a different question though :)).