If I try to execute a script whose only source line is an object:
{prop:'value'}
it is well versed (in both V8 and UglifyJS). Similarly, I can put the string or number myself as source code, and no syntax error is reported.
However, both V8 and UglifyJS themselves complain:
function(){}
I get Uncaught SyntaxError: Unexpected token ( .
Why is this interrupted when the object in the first example is beautiful? Only objects in javascript not working?
I understand that declaring an anonymous function without doing it will do nothing; it's not a question. I want to know why this is causing a parsing error.
javascript syntax anonymous-function parsing grammar
Flash
source share