JavaScript – Comments

Comments: Comments are used to describe the code or document. These are 2 types

  1. Single-line Comment
  2. Multi-line Comment

Single line Comment: It is represented by double forward slashes (//).

<!doctype html>
<html>
            <body>
                        <script> 
                                    var a=10; 
                                    var b=20; 
                                    var c=a+b; // + operator add values of a & b and store result into c 
                                    document.write(c); // write() – display information of web page 
                        </script>  
            </body>
</html>

Multi line Comment: It can be used describe the entire document.

/* This program is used to perform Addition operation of 2 numbers
And display result on Web page Using document.write() method */
<!doctype html>
<html>
            <body>
                        <script> 
                                    var a=10; 
                                    var b=20; 
                                    var c=a+b;
                                    document.write(c);
                        </script>  
            </body>
</html>
Scroll to Top