• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 2. Creating Your First Scripts > Adding Comments to Your Code

Adding Comments to Your Code

A script or function that consists of just a few lines is usually easy to read and understand. However, your scripts won't stay that simple for long, and these longer and more complex creations will be correspondingly more difficult to read. (This is particularly true if you're looking at the code a few weeks or months after you first programmed it.) To help you decipher your code, it's good programming practice to make liberal use of comments throughout the script. A comment is text—it could be 1 line or 10 lines—that describes or explains a statement or group of statements. Comments are ignored by the browser, so you can add as many as you deem necessary.

For short, single-line comments, use the double-slash (//) that I mentioned briefly earlier in this chapter. Put the // at the beginning of the line, and then type in your comment after it. Here's an example:


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint