Reputation: 30340
Purely a curiosity, but why does Chrome (31) raise SyntaxError: Unexpected token }
when executing the (invalid) statement void
from the JS console?
I understand that the JS engine should raise a syntax error - void
requires an argument. I don't understand what a }
has to do with it.
The same invalid statement, when executed from the URL bar with javascript:void
or in a web page, results in a more sensible SyntaxError: Unexpected end of input
.
Upvotes: 0
Views: 739
Reputation: 116030
If you run a debugger;
statement in the console, you'll see:
Your code is wrapped inside of with(console ...)
block. The unexpected }
is the one that closes the block. Mentally replace the debugger;
with a void
with no arguments, and you can see how you'd get that error.
Upvotes: 4