If I try to execute a script whose only source line is an object:
{prop:'value'}
it parses fine (in both V8 and UglifyJS). Similarly I can put a string or number on its own as source code and there is no syntax error reported.
However, both V8 and UglifyJS complain about this on its own:
function(){}
I get Uncaught SyntaxError: Unexpected token (
.
Why does this break when the object in the first example is fine? Aren't functions just objects in javascript?
I realise declaring an anonymous function without executing it won't do anything; that's not the question. I want to know why it causes a parse error.