Thursday, 3 July 2014

Chapter 4: JavaScript Comments

JavaScript comments:
You can simply add a comment in JavaScript by adding // before the code you want to be inside comment.
Example:

<html>
<head>
<title>Untitled Document</title>
</head>
<body>

<script>
// console.log("Hello World");
// alert("Hi world");
</script>
</body>
</html>

JavaScript ignores anything after // and begins after the next line.

You can also add multiple comment by adding /* before and */ after the code you wanted to comment.
Example:

<html>
<head>
<title>Untitled Document</title>
</head>
<body>

<script>
/*
    alert("This is a multiple comment.");
    alert("This also is a part of the comment.");        
*/
</script>
</body>

</html>

No comments:

Post a Comment