- In programming, comments can also be used to prevent some code lines from being executed. While testing it is more useful.
- Single-line comment out one line or a part of one line and do not need to be closed.
- Multiline comments can comment out block of code(a few lines) and need to be closed.
Single line comments start with
//. Anything that goes after
// This is a number array var arr1 = [1,2,3,4]; var x = 5; // Variable declaration var y = x + 99; // Different variable
Multi-line comments are more often used for formal documentations. start with
/* and end with
*/. Any text inside the
Below is the example for how to use the multi-line comments,
/*This is a number array. We are going to add another element to the arr1 */ var arr1 = [1,2,3,4]; arr1.push(5);
Happy Learning 🙂
Leave a Reply