samar
How to comment javascript code?
1 Answer(s)      4 years and 8 months ago
Posted in : JavaScript Questions

How to comment javascript code?

Advertisement
View Answers

November 10, 2010 at 11:43 AM


Comments can be added to explain the JavaScript, or to make the code more readable. With comments, you can add extra information pertaining to your code. Comments are ignored (i.e., are not processed as coding instructions) by the computer.

  1. Single-line comments- Single-line comments start anywhere in the line and continue to the end of the line. Single-line comments begin with a double forward slash (//),

For example-

// Description: This JavaScript code prints a simple message.
  1. Multiline comments- Multiline comments span multiple lines. Multiline comments start with slash-asterisk (/*) and end with asterisk-slash (*/) pair. For example,

    /* Author: Scripting Master Description: This JavaScript code prints a simple message.*/