It is fairly tricky, all things considered. It's one of
two syntactic "ambiguities" in the language that are, rather
unconventionally, resolved with a one-off rule. Basically the rule here is
that "no statement may begin with a FunctionExpression". Consider that:

This works:
foo();
function foo(){};

This doesn't:
foo();
!function foo(){};

One is an ExpressionStatement, the other is a FunctionStatement.

The other ambiguity is curly braces being overloaded for both block
statements and object literals. That too is resolved with a one-off rule of
"no statement may begin with an object literal".

On Thu, Mar 21, 2013 at 5:47 AM, AJ ONeal <[email protected]> wrote:

> First, I concede to the empirical evidence disproving my assertion that
> the expression was hoisted. I have been shown the light (in a way such that
> it has spoken unto mine own understanding) and I now believe. Thanks
> Geerten.
>
> This is why the paren placement boggles me:
>
> 42.toString() // Errorinated
> (42).toString() // Successified
> (42.toString()) // BELETED
>
> I would expect the same behavior here
>
> function () {} ().toString()
> (function () {}).toString()
> (function () {}.toString()) // WORKS !?!?!
>
> That's why I find it odd that the placement of the parens is unimportant.
>
> I don't know what the spec says about it, but the behavior appears
> inconsistent and therefore unintuitive.
>
> AJ ONeal
>
> --
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>
> ---
> You received this message because you are subscribed to the Google Groups
> "nodejs" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to