...

Web Technologies - JAVASCRIPT

Back to Course

Lesson Description


Lession - #200 Javascript Comments


The JavaScript comments are significant method for conveying message. It is utilized to add information about the code, warnings or ideas so that user can easily understand the code.
The JavaScript comment is ignored by the JavaScript engine for example embedded in the browser.

Benefits of JavaScript comments:



To make code straightforward(easy>
It can be utilized to elaborate the code so that end user can without much of a stretch understand the code.
To stay away from the unnecessary code It can likewise be utilized to stay away from the code being executed. Now and again, we add the code to perform some activity. In any case, later at some point, there might be need to disable the code. In such case, it is smarter to utilize comments.

Types of comments

  • Single line comment
  • Multiline comment

    Single line comment

    It is represented by double forward slashes (//>
    . It can be utilized previously, or after the statement.

    Let's seee an example

    
    <html>
    <body>
    <script>  
    // It is single line comment  
    document.write("hello javascript">
    ; </script> </body> </html>

    Output:


    Try it here

    Multi line comment

    It is represented by a forward slashes and astrict(/* ..*/>
    . It can be utilized previously, or after the statement.

    Let's seee an example

    
    <html>
    <body>
    <script>  
    /* It is multi line comment  
       demonstration example */
    document.write("hello javascript">
    ; </script> </body> </html>

    Output:


    Try it here