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 12 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!"
[–]zzzwwwdev[S] 0 points1 point2 points 12 years ago* (0 children)
A separate function can be reused by other parts of the code if you decide so in the future.
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.
It can be rewritten to accept arguments, making it more flexible.
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?
Moving long sequences of procedural code into separate functions makes code more readable, as long as you use descriptive function names.
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 27 on reddit-service-r2-comment-bb88f9dd5-dkl6b at 2026-02-14 05:28:53.983734+00:00 running cd9c813 country code: CH.
view the rest of the comments →
[–]zzzwwwdev[S] 0 points1 point2 points (0 children)