Richard's JavaScript Tutorials

Updated 07/18/14

Home
Animation
precachedImages
digitalClock
Object Tag (Audio)
Cookies.htm
Math_Object
Using CSS
The Style Object
Client_Info
customObject
functions
UsingArrays
comments
concatenation
documentwrite
ifelse
Loops
forms
Strings
variables

 

Adding comments to your JavaScript code

When using comments in your JavaScript code, there are two methods single line comments and multiple line comments.

The following line of code uses single line javascript comments

<!-- document.write() method example //-->
Any data enclosed in the <!-- and //--> will be hidden from older browsers
newer browsers such as Internet Explorer 6.0 that supports later versions of JavaScript will display the data written between
the <!-- hidden text //--> tags

Using multiple line comments in JavaScript is very similar to using single line comments.
Multiple line comments use the same opening and closing comment tags the only difference is that every line
that doesn't start with the opening tag starts with the javascript // element. Here is an example.

<!-- My original comments were here now let's add a few more lines
// Here is a second line of comments
// Here is a third line of comments
// this is the final line with the closing tag //-->

Now try substituting my code and add your own text to try creating your own javascript code using single and multiple line comments.

 

This site was last updated 07/08/14