[jQuery] Re: why coding like this:(function(){})();

2009-03-15 Thread mkmanning
I think this post has gone way off course, and yet there really isn't any disagreement among us; it's mostly imprecision in language giving rise to ambiguity :P My apologies to lovespring for making a simple question require so much scolling :) So to try and bring this back to the OP: 1.does it

[jQuery] Re: why coding like this:(function(){})();

2009-03-15 Thread mkmanning
" x=3; // This does _not_ change the global x!" No, it doesn't change the global, because it's declared with var in the function first, so x in the function isn't global, it's lexically scoped to the function; x in the inner function is lexically scoped to the containing function (x within the ou

[jQuery] Re: why coding like this:(function(){})();

2009-03-15 Thread Matt Kruse
On Mar 15, 12:00 pm, mkmanning wrote: > Not sure what you mean "inline" or by "scope the vars inside"; > variables declared inside the function are scoped "inside" (they have > lexical scope to the function), as long as they are preceded with the > var declaration (if not, they are global, even w

[jQuery] Re: why coding like this:(function(){})();

2009-03-15 Thread mkmanning
"withn the flow of text"? Still not getting the usage, maybe you can point me to a specific reference of "inline" as common usage in JavaScript. Inline in common JavaScript usage (since it is 99.9% of the time DOM related) usually refers to javascript (usually event related) within markup, such as

[jQuery] Re: why coding like this:(function(){})();

2009-03-15 Thread mkmanning
"withn the flow of text"? Still not getting the usage, maybe you can point me to a specific reference of "inline" as common usage in JavaScript. Inline in common JavaScript usage (since it is 99.9% of the time DOM related) usually refers to javascript (usually event related) within markup, such as

[jQuery] Re: why coding like this:(function(){})();

2009-03-15 Thread T.J. Crowder
> Not sure what you mean "inline" or by "scope the vars inside"; > variables declared inside the function are scoped "inside" Yes. Isn't that what I said? Re inline: I meant inline as in...well...inline. ;-) I'm not sure how else to say it; within the flow of the text rather than outside it.

[jQuery] Re: why coding like this:(function(){})();

2009-03-15 Thread mkmanning
Not sure what you mean "inline" or by "scope the vars inside"; variables declared inside the function are scoped "inside" (they have lexical scope to the function), as long as they are preceded with the var declaration (if not, they are global, even with this format). The closing/end parens creat

[jQuery] Re: why coding like this:(function(){})();

2009-03-15 Thread T.J. Crowder
Hi, On Mar 15, 12:55 pm, lovespring wrote: > (function(){})(); > does it conform to the grammar? Yes, it does. That line defines a function inline: (function(){}) ...and then calls it immediately using () like any other function: (function(){})(); (You need the parens around the de