Hi. very nice explanation but what i don't fully understand is why the grouping 
operator makes the parenthesis following the function declaration work as call.

(function(x){alert(x)}(1));

why this is not treated the same way as:

function(x){}(1);


On Dec 31, 2010, at 7:46 AM, Dmitry A. Soshnikov wrote:

> Just for those who don't use Twitter. I've just edited my "ES3.Ch5.Functions" 
> article in respect of explanation the "surrounding parentheses". The thing 
> is, that almost _all_ explanations (in books, articles, etc) were at least 
> very incomplete (and even wrong).
> 
> So, why does this code produces a SyntaxError:
> 
> function () {
>  ...
> }()
> 
> // or with name
> 
> function foo() {
>  ...
> }();
> 
> Try to provide as much complete explanation as possible. Also try to answer 
> without cheating ;) The correct and full explanation is here: 
> http://dmitrysoshnikov.com/ecmascript/chapter-5-functions/#question-about-surrounding-parentheses
> 
> Dmitry.
> 
> P.S.: Happy New Year!
> 
> -- 
> 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]

-- 
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]

Reply via email to