Javascript Comments
----------------------------------------------
Lets take look how to do javascript commenting but before that why its needed.
- Javascript comment is used in order to explain the code
- To prevent the execution when we do testing
- For debugging
Their is two ways to do comment single and multi-line comment.
1)Single line comment
For single line comment we use //
before any string
// Declare x, give it the value of 5
var num = 5;
//var numTwo = 5;
// Write num to text:
document.getElementById("inputNum").innerHTML = num;
2)Multi-line comment
Multi-line comments start with /*
and end with */
.
/*
This id demo text to explain how multi-line comment works
*/
document.getElementById("input1").innerHTML = "JavaScript multi-line Comments";
Categories: Java Script Tags: #JavaScript,