Add comments to scripts

Posted by David on March 12th, 2007 filed in JavaScript

The JavaScript interpreter ignores comments. Comments do have value, though; they’re very useful for explaining things to human readers of your script. Of course, including yourself.

1) Single-line comment

//Single-line comments don’t require an ending slash.

2) Multiple-line comment

/* This comment can span multiple lines. Always remember
to close it. Though; if you forge. you’ll get weird errors when
you try to display your script. */

Note:
Don’t mix up HTML comment <!– HTML comment –> and JavaScript comment.

Related posts

Comments are closed.