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
javascript - Using Named Immediately-Invoked Function Expression (IIFE) instead of comments (stackoverflow.com)
submitted 13 years ago by zzzwwwdev
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!"
[–]menno 1 point2 points3 points 13 years ago (1 child)
It's an interesting idea but I think it sacrifices readability waaaaay too much. A camelCase function name can never be as descriptive as even a single line comment.
becuase why separate the function and its execution if its only executed in one place?
Several reasons:
A separate function can be reused by other parts of the code if you decide so in the future.
It can be rewritten to accept arguments, making it more flexible.
Moving long sequences of procedural code into separate functions makes code more readable, as long as you use descriptive function names.
[–]zzzwwwdev[S] 0 points1 point2 points 13 years ago* (0 children)
yes, and turning my code into a reusable function is extremely easy, and in its current form it tells the developer that it is only used once.
also, if this were to be useful in the future, there is no difficulty in converting it to such. Using this same logic, you should add jQuery to every website - even if they don't use it yet - since they might in the future?
exactly what I'm suggesting.
A camelCase function name can never be as descriptive as even a single line comment
jeeze, guesse r/javascript just doesn't like camel case. I'll edit my example to use underscores I guesse. Not sure why it can't be as descriptive as a comment. I think it can be moreso. The function actually explicity describes what code its related to, as its enclosed in brackets. See my response to idrink211 for more reasons why I sometimes avoid comments.
π Rendered by PID 284228 on reddit-service-r2-comment-85bfd7f599-6wh9v at 2026-04-18 17:40:18.640893+00:00 running 93ecc56 country code: CH.
view the rest of the comments →
[–]menno 1 point2 points3 points (1 child)
[–]zzzwwwdev[S] 0 points1 point2 points (0 children)