Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #10153
| From | "J.R." <groups_jr-1@yahoo.com.br> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: FAQ Topic - What is (function(){ /*...*/ })() ? (2012-01-06) |
| Date | 2012-01-11 21:44 -0200 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <jel6t0$8v3$1@speranza.aioe.org> (permalink) |
| References | <4f063989$0$283$14726298@news.sunsite.dk> <h0gqg7lji6327vo8eeiuv71urmrvger83q@4ax.com> |
On 11/01/2012 05:54, Hans-Georg Michna wrote:
> On Fri, 06 Jan 2012 00:00:02 +0000, FAQ server wrote:
>
>> -----------------------------------------------------------------------
>> FAQ Topic - What is (function(){ /*...*/ })() ?
>> -----------------------------------------------------------------------
>>
>> This is an anonymous FunctionExpression that is called
>> immediately after creation.
>>
>> Variables declared inside a function are not accessible from
>> outside the function. This can be useful, for example, to hide
>> implementation details or to avoid polluting the global scope.
>>
>> <URL: http://yura.thinkweb2.com/named-function-expressions/>
>> <URL: http://jibbering.com/faq/notes/closures/>
>> <URL: http://dmitrysoshnikov.com/ecmascript/chapter-5-functions/#question-about-surrounding-parentheses>
>>
>>
>> The complete comp.lang.javascript FAQ is at
>> http://jibbering.com/faq/
>
> It may be a good idea to mention that it is sometimes written
> as:
>
> (function(){ /*...*/ }())
>
> Note the different arrangement of the last parentheses.
>
> I believe this is functionally equivalent.
Besides, JSLint complains about any different form other than this:
(function () {
// ...
}());
Notice the trailing semi-colon (;)
--
Joao Rodrigues (J.R.)
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
FAQ Topic - What is (function(){ /*...*/ })() ? (2012-01-06) "FAQ server" <javascript@dotinternet.be> - 2012-01-06 00:00 +0000
Re: FAQ Topic - What is (function(){ /*...*/ })() ? (2012-01-06) Hans-Georg Michna <hans-georgNoEmailPlease@michna.com> - 2012-01-11 08:54 +0100
Re: FAQ Topic - What is (function(){ /*...*/ })() ? (2012-01-06) "J.R." <groups_jr-1@yahoo.com.br> - 2012-01-11 21:44 -0200
Re: FAQ Topic - What is (function(){ /*...*/ })() ? (2012-01-06) Hans-Georg Michna <hans-georgNoEmailPlease@michna.com> - 2012-01-12 09:26 +0100
Re: FAQ Topic - What is (function(){ /*...*/ })() ? (2012-01-06) "J.R." <groups_jr-1@yahoo.com.br> - 2012-01-22 07:10 -0200
Re: FAQ Topic - What is (function(){ /*...*/ })() ? (2012-01-06) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-03-13 20:54 +0100
csiph-web