kisi bhi code ke bare me notes/detail likhne ke lie ya explanation likhne ke lie comment ka use karte hain. for example code kis date ko likha gya, code kisne likha, yeh code kis lie likha gya etc comments me likha jata hai.
Code ko explain krne se other developers ko complext logic/code samaj aa jata hai. Koi b commented code run ni hota hai and interpreter b us code ko ignore krta hai. Isi trah yadi hum testing krte time kisi code ko comment krna chahte hain to kr skte hain.
Comments 2 types ke hote hain:
- Single-line comments (Jo ki kisi line ko ya line ke kisi hisse ko comment krne ke kaam aata hai)
- multi-line comments (Jiska use kisi code block ko comment krne ke lie hota hai).
Example of Single line Comment: Single line comment 2 forward slashes / ke sath start hota hai and aur us puri line ko end tak comment kr deta hai
// This is a single-line comment
Example of Multi line comment: Multi comment forward slash and _ asterisk ke sath start hota hai aur _ asterisk and forward slash ke sath end hota hai.
/* This is a
multi-line comment */