Comments In JavaScript
Comments are used to add hints, notes, suggestions, or warnings to JavaScript code. This can make it easier to read and understand. They can also be used to disable code to prevent it from being executed; this can be a valuable debugging tool.
JavaScript has two long-standing ways to add comments to code and a special comment for special usage:
Line comments
The line comments makes all text following it on the same line into a comment. For example:
Block comments
The second way is the /* */ style, which is much more flexible. For example, you can use it to group a bunch of text together:
Hashbang comments
The hashbang comment is a special comment used to specify the path to a particular JavaScript engine that should execute the script. It is only valid at the absolute start of a script or module. Note also that no whitespace of any kind is permitted before the #!
Conclusion
Comments can give more clarity to your code and makes you a better communicated.