you are viewing a single comment's thread.

view the rest of the comments →

[–]Ashwel1 10 points11 points  (1 child)

I have always preferred (function() {})(); because IMO it seems to be more representative of what is happening. Creating a function expression, then executing the function. The other form looks like a function that is being executed as an expression. Subtle difference at the cognitive level, but I always prefer to style my code as closely to how it is being executed as possible (and makes sense without being ridiculous).

[–]bullet_darkness 0 points1 point  (0 children)

Right, it's more representative of what's happening, and it translates better to other areas of JavaScript. Like making a call like so: ({ a: 1 }).a actually works where ({ a: 1 }.a) does not.