Comments
Sometimes it is helpful to make notes for yourself to keep track of what is going on in a script. As in HTML, JavaScript allows you to make comments in your code but offers a few different ways to do it. The first style of comment uses two forward slashes:
// this is a comment
This type of comment makes the interpreter ignore the remainder of the line. The second method allows you to comment out multiple lines:
/* this is a multi-line or block comment */
Apart from using comments to make notes to yourself, they are also quite useful in the debugging process: if you can’t seem to figure out where an error is coming from, you can comment out a line or section of the code to see if it is the culprit.
Get Web Design in a Nutshell, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.