JavaScript Comments
Comments :
multiple lines of code temporally you want to close it, that time you can use it.
If you are working n a team one of them had written a complex code, to understand other also n a team that time also use comment
Comments are two types
- Single line comments
- Multi line comments
Single line comments are starts with //
Example:
<!DOCTYPE html> <html> <body> <h1> Single-line comments </h1> <p id="demo"></p> <script> let x=5; //declare x, it gve value of 5 let y=x+7; //declare y, it gve value of x+7 let z=x+y; Document.getElementById("demo").innerHTML =z; </script> </body> </html>
Multi line comments are starts /* statement ends with /
/ the below code will change the heading and the paragraph with itallic*/
<!DOCTYPE html> <html> <head> <title> Multi-line comments </title> </head> <body> <h1 id ="Heading"></h1> <i><p id="Pitalc"></p></i> <script> Document.getElementById("Heading").innerHTML ="JAVASCRIPT multi-line comments"; Document.getElementById("Pitalc").innerHTML ="JAVASCRIPT multi-line comments"; </script> </body> </html>