Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #7990
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | Eric Bednarz <bednarz@fahr-zur-hoelle.org> |
| Newsgroups | comp.lang.javascript |
| Subject | Re: calling function within (function() {...})(); |
| Date | Fri, 04 Nov 2011 16:35:52 +0100 |
| Organization | Eric Conspiracy Secret Labs |
| Lines | 51 |
| Message-ID | <m2wrbfaoiv.fsf@nntp.bednarz.nl> (permalink) |
| References | <j-mdnaRhWZiHRS7TnZ2dnUVZ_uednZ2d@westnet.com.au> <j90o0s$vmv$1@dont-email.me> <m21utoav44.fsf@nntp.bednarz.nl> <8928443.SEqChMirdb@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 fO6EKFLsxs3XlGozXo07+gUS2bTeboOZLP7nxdXLC7gD9c7eRx |
| Cancel-Lock | sha1:tLUl2h7txNf0eeJkcnDQ0dGZ7Z0= sha1:6pKF8ykayfycQ/RFGcUrQ7GRAlE= |
| 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:7990 |
Show key headers only | View raw
Thomas 'PointedEars' Lahn <PointedEars@web.de> writes:
> Eric Bednarz wrote:
>
>> Gregor Kofler <usenet@gregorkofler.com> writes:
>>> Am 2011-11-04 13:18, Andrew Poulos meinte:
>>>> var x = (function(){
>>>> return {
>>>> a : function(){},
>>>> b : function(){}
>>>> };
>>>> })();
>> var x = (function () {
>> function a() {
>> b();
>> }
>> function b() {
>>
>> }
>> return {
>> a: a,
>> b: b
>> };
>> }());
>
> There is no inherent advantage in that. In fact, it is slightly less
> efficient than the original code because the `a' and `b' identifiers need to
> be resolved first,
If a, b[, n] are used a lot in a context where they need not be methods
of an object, it would seem futile (and – depending on the number of
calls – quite inefficient) to me to call them as methods of an object
nevertheless.
>> 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 asynchronous call is unnecessary here, though.
That’s the problem of all artificial example code. In the origignal
code, calling a function expression that does nothing but returning an
object was unnecessary, too.
--
λ
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
calling function within (function() {...})(); Andrew Poulos <ap_prog@hotmail.com> - 2011-11-04 23:18 +1100
Re: calling function within (function() {...})(); Gregor Kofler <usenet@gregorkofler.com> - 2011-11-04 14:06 +0100
Re: calling function within (function() {...})(); Eric Bednarz <bednarz@fahr-zur-hoelle.org> - 2011-11-04 14:13 +0100
Re: calling function within (function() {...})(); Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-11-04 15:49 +0100
Re: calling function within (function() {...})(); Eric Bednarz <bednarz@fahr-zur-hoelle.org> - 2011-11-04 16:35 +0100
Re: calling function within (function() {...})(); Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-11-04 20:44 +0100
Re: calling function within (function() {...})(); Eric Bednarz <bednarz@fahr-zur-hoelle.org> - 2011-11-04 21:16 +0100
Re: calling function within (function() {...})(); Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-11-04 21:24 +0100
Re: calling function within (function() {...})(); Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-11-04 21:46 +0100
Re: calling function within (function() {...})(); Eric Bednarz <bednarz@fahr-zur-hoelle.org> - 2011-11-04 23:29 +0100
Re: calling function within (function() {...})(); Scott Sauyet <scott.sauyet@gmail.com> - 2011-11-04 10:29 -0700
Re: calling function within (function() {...})(); Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-11-09 15:17 +0100
Re: calling function within (function() {...})(); Eric Bednarz <bednarz@fahr-zur-hoelle.org> - 2011-11-09 20:13 +0100
Re: calling function within (function() {...})(); Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-11-11 23:26 +0100
Re: calling function within (function() {...})(); Eric Bednarz <bednarz@fahr-zur-hoelle.org> - 2011-11-11 23:31 +0100
Re: calling function within (function() {...})(); Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-11-12 00:38 +0100
csiph-web