News for hackers. Stuff that matters.
Re:Implementing bookmarklets in JavaScript by dave1010uk on Saturday June 11, 2011 @04:58AM (#2643508)
The former give the following message in http://jslint.com

  Problem at line 1 character 17: Move the invocation into the parens that contain the function.
Crockford seems to prefer the latter but I don't know why.
Re:Implementing bookmarklets in JavaScript by rauschma on Saturday June 11, 2011 @07:49AM (#2643683)
This is purely a matter of taste. You only need the parens to tell JavaScript that it is a function expression and not a function declaration (a statement). The outer parens make an IIFE look even more block-like to me, which is why I use it. Any other prefix that tells JS that the IIFE is an expression is OK, too. For example:

    +function() { console.log("bla") }();
But: this one converts the result to a number, which you don’t want if you need the result of the IIFE. On the other hand, in places where you need that, there is usually no ambiguity with statements, anyway, and you don’t need any kind of prefix.

    var abc = function() { return "abc" }();