javascript comment : easy how to

Posted under javascript sample code On By mohammed.mutawe

JavaScript comment

When writing advanced JavaScript code, the difficulty of parsing the code will begin to appear again, which leads to taking a lot of time in analyzing the code, especially when you modify the functions of many lines. JavaScript is like other languages, and it provided writing comments aside to make it easier for developers.



  • Types and forms of comments.
  • Do an example.



You can add a comment in one line, and all you will do is reserve one line from the editor only to write your notes as follows:

// I am javascript comment

Or you can write your comment after executing a specific command in JavaScript as follows:

 document.write("Javascript code here !");// I am javascript comment


There are many ways that you can activate or deactivate the JavaScript code, and you can do this by:

// document.write("I deactivated this code by considering as a comment!");

You can also add multiple line comment to become like so :

You can do this by creating multiple lines of comment
to become like this
and this is very effective way if you want to write paragraph comment



After we explained how to use comment correctly you can put these lines of code in your page to see difference between them

<!DOCTYPE html>
<html lang="en">
  <meta charset="utf-8">
  <title>Types of comment in javascript</title>
  <link href="style.css" rel="stylesheet" />
/*Welcome to javascript comment definition
you learned how to create first comment by using multiple line

// you learned how to create first comment by single line




  • Third edition JavaScript

Leave a comment

Your email address will not be published. Required fields are marked *