Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

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

Comments

Make frequent use of comments to aid others in understanding your code. Use comments when:

  • Code is difficult to understand.

  • The code might be mistaken for an error.

  • Browser-specific code is necessary but not obvious.

  • Documentation generation is necessary for an object, method, or property (use appropriate documentation comments).

Single-Line Comments

Single-line comments should be used to documentation one line of code or a group of related lines of code. A single-line comment may be used in three ways:

  • On a separate line, describing the code beneath it

  • At the end of a line, describing the code before it

  • On multiple lines, to comment out sections of code

When on a separate line, a single-line comment should be at the same indentation level as the code it describes and be preceded by a single line. Never use multiple single-line comments on consecutive lines; use a multiline comment instead.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint