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.
<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