> The thing is that (almost?) all explanations (I repeat -- books, articles,
> etc) talked about `calling`, that is wrong. While the reason is that
> parentheses at the end are not parentheses of a call (`Arguments`
> production), but just a grouping operator (without an expression inside)
> which causes the error.
>
> function foo(x) {
> alert(x)
> }(1);
>
> There is no error. But it's not a call. It's a FD and the following grouping
> operator with the expression `1`. I.e. it's:
>
> function foo(x) {
> alert(x)
> }
>
> (1);
So the parses treats these as two distinct statements, that is why a semicolon
is not automatically inserted after a FD?
>
> And since an empty grouping operator () causes an error, exactly this is the
> reason:
>
> function foo(x) {
> alert(x)
> }();
>
> and not in "FD cannot be _called_", since it's not about calling at all.
This was new to me, I had read or perhaps just assumed it was a call on a FD
prior, thanks for clearing that up.
>
--
To view archived discussions from the original JSMentors Mailman list:
http://www.mail-archive.com/[email protected]/
To search via a non-Google archive, visit here:
http://www.mail-archive.com/[email protected]/
To unsubscribe from this group, send email to
[email protected]