JavaScript Tutorial #3 – Comments in JavaScript

JavaScript has the support for both single line and multi line comments like C++ or C#.

The single line comment is usually represented by // and the text between // and the end of the line is treated as comment.

The multiline comment is represented by the characters /* and */ and the text between them is a comment and can span across multiple lines.

Below is an example of the JavaScript code with the comments.

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>Ginktage.com Home Page</title>
    <script language="javascript" type="text/javascript">
        document.write('Welcome to Ginktage.com JavaScript Tutorial');
        // This is single line comment
        /* This is a multi line comment 1
        This is a multi line comment 2
        */
    </script>
</head>
<body>
</body>
</html>

image

If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

Leave a Reply


x

Interesting BlogPosts to read

How to Flatten a 2-D array in JavaScript ?
You can flatten a 2-D array in JavaScript using the concat and apply method as shown in the below co...
How to convert from Degree to Radian in JavaScript ?
Assume that you have an angle in degree and you wish to convert it to radians in JavaScript so that ...
How to Prevent your App from being Installed on Windows Phone that does not match the requirements ?
There are times when you want to prevent your app from being downloaded and installed on the Windows...