r/AskProgramming • • Jan 12 '25

Commenting Style in JavaScript

QQ: What is the best practice for commenting styles?

  1. Single Line comment
  2. Multiple Line comment
  3. Using JSDoc Style
2 Upvotes

3 comments sorted by

View all comments

Show parent comment

3

u/bothunter Jan 13 '25

If one line will suffice, use a single line comment.  If you need to write a whole block of text, use a multi line comment(or better yet, fix your code so the comment is not necessary) and jsdoc to document how your methods work. (Even if you don't use jsdoc itself, many IDEs will use jsdoc comments to assist with intellisense)