Usually when we write down the code, it seems very clear to us but when we try to update the code after some time we might get face trouble while doing so ( Due to the complexity of the code). Here COMMENTS will help us. Good programmers must use comments in his code so that it could be more understandable for human.

“Every program is MACHINE READABLE but a good program is also human readable” –unknown

There are two types of comments

  1. Single Line comments
  2. Multi line comments

Single line comments can comment a single line of code , the line we comment will not be executed. We can do it by just placing ‘//’ in the start of the code we want to comment

Var a=3; //This is a comment but before the comment start we already declare a variable

//var b=5; this is also a comment and this line would not be decoded, so nothing would happens

In first statement we actually make a variable ‘a’ and also assign it a value but in second statement nothing would be happened

Multiline comment is use to comment a number of lines of code. It starts with ‘/*’ and end uo with ‘*/’

For example:

/* Var a=3;

var b=5;

alert(a+b);

Nothing would be happens as all this code is in a comments block. */

This is same as :

//Var a=3;

//var b=5;

//alert(a+b);

 

That’s very much it for this toast. I hope you enjoy it. Please leave your feedback in comments. We are also available for coaching on Skype  😉