| Viewed 78 times

How to comment in javascript


How to comment in javascript

1 Answer
Mikdam Qandeel
Answered
3

Comments in javascript or notes you can use it to describe or define something, but you don't want the text to appear on the browser. In addition, you can use it to stop a specific function. There are two ways to do that comment.

The first way is by using // (double slash)for a single line comment.

Example:

<html>
<body>
   <script>

        document.write("Welcome to Qandeel Academy");
       //single line comment - I won't appear!

    </script>
</body>
</html>

Output:

Welcome to Qandeel Academy

 

Abd the second way is by using /* */ and often it's used for multi-line of comments.

Example:

<html>
<body>
   <script>

        document.write("Welcome again to Qandeel Academy");
       /*
          I am the first comment,
          And I am the second one!
          We won't appear!!
       */

    </script>
</body>
</html>

Output:

Welcome again to Qandeel Academy