Articles → JavaScript → Comments In Javascript
Comments In Javascript
Purpose
 
Types Of Comments
 
- Single-line comments
- Multiline comments
Single-Line Comments
 
// This is a single-line comment.
Multiline Comments
 
/*
	This is a multiline comment .
      In this you can write any no.of lines.
*/
Example.
 
<!DOCTYPE html>
<html>
<head>
    <title>Comments example</title>
    <script language="JavaScript">
        /*
            Code added by : GyanSangrah
            Code added on : September 13, 2010        
        */
        function ClickMe() {
            // This piece of code will fire an alert.    
            // It is important to add semi colon at the end to avoid 
            // any JavaScript error.
            alert("Hi, this is a comments sample");
        }
    </script>
</head>
<body>
    <form>
        <input type="button" name="btnComments" value="Click Me" onclick="javascript:ClickMe();" />
    </form>
</body>
</html>
Try It
| Posted By  - | Karan Gupta | 
|  | 
| Posted On  - | Tuesday, December 28, 2010 |