The text / code lines of javaScript are used to comment it is not displayed in the web page to the user, the web developer gives the comment for themselves in the source code, in this the description of the code (Explanations) can be given which read the source code. This helps in understanding and therefore developers use the comment.
Symbol of double forward slash (//) is placed next to the text / code lines in javaScript that have to be commented.
Syntax
//-----------
Symbol of asterisk (*) and forward slash (/) is placed at the end of forward slash (/) and asterisk (*) and text / code lines to comment two or more text / code lines in javaScript.
Syntax
/*
------------
------------
*/
Example 1
<!DOCTYPE html> <html> <head> <title></title> </head> <body> <script> //single line comment Example document.write("single line comment Example "); </script> <br> <script> /* multiline comment example multiline comment example */ document.write("multiline comment example"); </script> </body> </html> |
Output
single line comment Example |