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


Groups > comp.lang.javascript > #14259

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

From Matt McDonald <matt@fortybelow.ca>
Newsgroups comp.lang.javascript
Subject Re: function(){}() and subsequent calls
Date 2012-05-31 09:57 -0600
Organization A noiseless patient Spider
Message-ID <jq84e2$u92$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


On 12-05-31 01:12 AM, Andrew Poulos wrote:
> 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".

JSLint (and by proxy, Crockford) desires the right
parenthetical of an immediately invoked function expression
to follow the invocation. An example follows.

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

will pass JSLint (`"use strict";` dogma aside).

> BTW I notice that <http://www.jslint.com/> has a nice new UI.

I disagree. I find it hideous.

-- 
Matt McDonald: Web/Flash Developer; Edmonton, Alberta, Canada

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