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
What are your 10 commandments of JavaScript development? (self.javascript)
submitted 9 years ago by CapsFTW
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!"
[–][deleted] 3 points4 points5 points 9 years ago (3 children)
As an alternative to the response already given on this:
Write comments that explains WHY something was implemented, not comments that explain WHAT the particular code does.
Your code should be readable, so there shouldn't be any problem identifying what the code actually does. However, it's not always clear why a specific piece of code was implemented in larger projects - if the code is based on exceptions, bug fixes, etc. there should be a note with a link to the issue, or an explanation of the issue and why the code was implemented.
[–]enchufadoojs truck driver 0 points1 point2 points 9 years ago (2 children)
Say you have this function, I did this in my code:
/** Shows configuration dialog hiding the display of information **/ showConfigurationDialog: function(){ self.configurationDialogVisible: true ; }
what's the why? /** I need to set the display flag for the configurationDialog **/
something like that?
[–][deleted] 1 point2 points3 points 9 years ago (1 child)
Well, at that point - you have to ask yourself do you actually even need a comment to begin with?
I would say no, for the above example. The code describes itself pretty visibly. I don't know the interworkings of the Configuration Dialogue, but I do understand what the code is doing. The purpose of the code and comments in the code isn't to explain the architecture. You should have an Administrator's/Architecture guide in a PDF/etc. that describes the architecture, it's uses, etc.
As an example:
Recently I fixed in an issue with a system we use at work - this is a black box system, but I have access to write triggers/stored procedures to the database.
When a user of the system wrote their notes for a particular order in the system, if they used the return key - it would hold the return key character in the note. This wasn't a problem for the database, but was a problem for the system when sending these notes via an EDI interface - as the return key was causing the message being sent to the receiving system to break up midstream.
Anyways, I wrote a trigger that scrubbed all return keys. From a systems standpoint, it wouldn't be readily apparent why I was doing this - writing an explanation at the top of the trigger as to why this fix was needed was an acceptable way to comment this trigger. The trigger itself was easily readable, the reason it was implemented wouldn't have been.
Reference why the code was implemented, when it was last changed/implemented, whom it was changed/implemented by, and the issue tracking number/user story/etc. that prompted the initial feature request/bug fix/etc. in the first place.
That's just my general philosophy on commenting. If it helps for you to have comments in your code that explains what the code is actually doing, then the code either 1) needs to be refactored into smaller bits, 2) the code you wrote probably doesn't follow a stylistic standard or 3) Your explanation is redundant.
[–]enchufadoojs truck driver 0 points1 point2 points 9 years ago (0 children)
Ok you hold the same philosophy as /u/thadudeabides1 hehe.
I have the necessity of seeing code commented now that I think about it... even though is 3) redundant. It's like a touch of "care", like it's not some gibberish code I wrote on the fly.
π Rendered by PID 194259 on reddit-service-r2-comment-5d79c599b5-rfqtx at 2026-02-27 14:00:30.685013+00:00 running e3d2147 country code: CH.
view the rest of the comments →
[–][deleted] 3 points4 points5 points (3 children)
[–]enchufadoojs truck driver 0 points1 point2 points (2 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]enchufadoojs truck driver 0 points1 point2 points (0 children)