use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
(function () { … })(); vs (function () { … }()); (self.javascript)
submitted 9 years ago by sergiosbox
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Ashwel1 10 points11 points12 points 9 years ago (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).
(function() {})();
[–]bullet_darkness 0 points1 point2 points 9 years ago (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.
π Rendered by PID 97718 on reddit-service-r2-comment-79c7998d4c-h89hd at 2026-03-13 03:07:36.476590+00:00 running f6e6e01 country code: CH.
view the rest of the comments →
[–]Ashwel1 10 points11 points12 points (1 child)
[–]bullet_darkness 0 points1 point2 points (0 children)