Do you comment your JavaScript code?
Updated by Brady Stroud [SSW] 1 year ago. See history
The goal is to write clear, concise and meaningful comments. They should describe your code in a way you or others understand what that particular piece of code does.
In other words, let your code speak for itself.
How to comment in JavaScript?
- Single-line comments - begin with a double forward slash (//)
- Multiline comments - start with slash-asterisk (/*) and end with asterisk-slash (*/) pair.
Generally use line comments. Use multiline comments for formal documentation and for commenting out.
Comments are ignored (not processed as coding) by the browser, however it makes you code heavier, so always try to keep your comments short by writing only what's needed to convey the idea.
document.write ("Example!"); // prints a message
Figure: Although this example sounds unnecessary for a developer, it shows clearly how comment should be kept simple and informative
Categories
Need help?
SSW Consulting has over 30 years of experience developing awesome software solutions.