Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #14253

Re: function(){}() and subsequent calls

From Gregor Kofler <usenet@gregorkofler.com>
Newsgroups comp.lang.javascript
Subject Re: function(){}() and subsequent calls
Date 2012-05-31 13:40 +0200
Organization A noiseless patient Spider
Message-ID <jq7lcb$354$1@dont-email.me> (permalink)
References <z42dnVxvhJ19m1rSnZ2dnUVZ_vCdnZ2d@westnet.com.au> <jq74ed$s3p$1@news01.versatel.de> <fcidnaenHatRhFrSnZ2dnUVZ_qCdnZ2d@westnet.com.au>

Show all headers | View raw


Am 2012-05-31 09:12, Andrew Poulos meinte:

> Ah, so if I want it called immediately and still be available for
> subsequent calls I tried this
> var foo;
> (foo = function(){})();
> which "works" but JSLint says "Bad invocation".

While it works, it is hard to follow. Whats wrong with

var foo = function() {...};
foo();

*Much* easier to understand (particularly with a "real" function body), 
and just as efficient.

Gregor


-- 
http://vxweb.net

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

function(){}() and subsequent calls Andrew Poulos <ap_prog@hotmail.com> - 2012-05-31 15:51 +1000
  Re: function(){}() and subsequent calls Holger Suhr <holgerholgerde@yahoo.de> - 2012-05-31 08:51 +0200
    Re: function(){}() and subsequent calls Andrew Poulos <ap_prog@hotmail.com> - 2012-05-31 17:12 +1000
      Re: function(){}() and subsequent calls Gregor Kofler <usenet@gregorkofler.com> - 2012-05-31 13:40 +0200
      Re: function(){}() and subsequent calls Matt McDonald <matt@fortybelow.ca> - 2012-05-31 09:57 -0600
        Re: function(){}() and subsequent calls Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-06-01 01:12 +0200

csiph-web