Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.musoftware.de!wum.musoftware.de!news.mind.de!news.cs.uni-magdeburg.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Eric Bednarz Newsgroups: comp.lang.javascript Subject: Re: calling function within (function() {...})(); Date: Fri, 04 Nov 2011 21:16:36 +0100 Organization: Eric Conspiracy Secret Labs Lines: 20 Message-ID: References: <8928443.SEqChMirdb@PointedEars.de> <2999240.SPkdTlGXAF@PointedEars.de> Reply-To: ebednarz@gmx.net Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: individual.net rViT20Bsx+TUyXnWFiNCeAaQnf2TLsoo9rfbWWyp7usVNv5vb/ Cancel-Lock: sha1:Z38/lwdzblBy5AifJTa0/MSWgM8= sha1:RfAeQfjMn6aiHZaZoeySlgn67Y0= X-Eric-Conspiracy: There is no conspiracy User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.3 (darwin) Xref: x330-a1.tempe.blueboxinc.net comp.lang.javascript:8008 Thomas 'PointedEars' Lahn writes: > Eric Bednarz wrote: >>>> window.setTimeout(x.a, 0); >>> >>> window.setTimeout(function() { x.a(); }, 10); >> >> You don’t say (I suppose creating a superfluous function object is >> justified by not resolving those pesky identifiers first :^) > > The Function instance is not superfluous. If you do not use the function > expression here, then only the reference to `x.a' will be called, which > means that `x.a' will be called as a method of the object that `window' > refers to, or if you will, the global object. As a result, `this' in `x.a' > would not refer to the same object as `x', but to the other object. That’s why I provided that example. I don’t know what makes you think that you have to explain that (or what the ‘module pattern’ is) to me.