Javascript Commenting
Comments allow you to write
notes to yourself within your
program. These are important
because they allow someone to
browse your code and understand
what the various functions do or
what your variables represent.
Comments also allow you to
understand your code if it's been
a while since you last looked at
it.
In JavaScript, you can write both
one-line comments and multiple
line comments. The notation for
each is different though. For a
one line comment, you precede your
comment with //. This indicates
that everything written on that
line, after the //, is a comment
and the program should disregard
it.
For a multiple-line comment,
you start with /* and end with */
. It is nice to put an * at the
beginning of each line just so
someone perusing your code
realizes that he/she is looking at
a comment (if it is really long
this helps). This is not necessary
though.
The following are examples of
comments in JavaScript.
// This is a single line comment.
/* This is a multiple line comment
with only one line. */
/* This is a multiple line
comment.
* The star (*) at the beginning of
this line is optional.
* So is the star at the beginning
of this line. */
|
|
|
|