How to Create a Comment in Javascript

Javascript’s comment symbol is the dual // at the beginning of the line.

Comments become helpful when writing Javascript. Using the comment function forces the computer to ignore or skip everything else on the line. Comments let us separate sections of the code, write reminders and notes, annotate where snippets came from, and let us disable lines of code for troubleshooting.

Example:

//This is a comment.
//The computer executing Javascript will ignore everything after the dual forward slashes.

2 Responses to “How to Create a Comment in Javascript”

  1. Don’t forget about multi-line comments Steve. They begin with /* and end with */ so you can define an end point for your comment.

    This is useful if you are typing out multiple lines for your comment or if you are adding a comment WITHIN a line of code and need the comment to end.

    Good tut.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>