The HTML and JavaScript comments are used in the same block but serve different purposes. The HTML comment is used to prevent the JavaScript code appear as plain text for those users that are running an older browser version that does not support JavaScript. The JavaScript comments are used to add a notation to your JavaScript code or prevent a JavaScript statement from executing, during the debugging process.
Single-line Comments
Single-line comments start with //. The following example shows the use of a single-line comment.
Multi-line Comments
There may be instances where you need to add multiple-line comments to your scripts. While you could simply add double slashes at the beginning of each line, it is not as convenient. This is where the multi-line comment tags may be used. Multi-line comments consist of the opening comment tag /*, the comments themselves, followed by the closing comment tag */. Here is an example of a multi-line comment: While it may seem like a tedious task, take the time to add meaningful comments. It not only makes your JavaScript easier to read but also helps you troubleshoot bugs in the script.