Learning JavaScript tutorial – JavaScript Comments
JavaScript Comments allows us to add remarks and a well written explanation about the working of JavaScript code. JavaScript Comments make the code more readable, understandable for future reference. Commenting your JavaScript code makes it easier for others to understand. To increase re-usability of a JavaScript code be, sure to include comments in your scripts. Commenting your JavaScript code is the best practice of JavaScript programming and suits to your aspect of good programming style.
Any comments you include in your JavaScript code will simply ignored by the JavaScript interpreter. JavaScript supports both C++ and C-style comments. JavaScript supports two types of comments, Single-line comments and multiple-line comments.
JavaScript Single line Comments
JavaScript Single line comments start with double Forward Slash (or Foreslash). Single-line comments which begin with double forward slash (//), causing the interpreter to ignore everything from the appearance point of double forward slash (//) to the end of the line.
// This is a single-line comment.
var iCount = 5; // This line will ignore by JavaScript interpreter
JavaScript Multiple line Comments
Along with Single line Comments, JavaScript allows us to Comment Multiple line. Every line of code between /* and */ is treat as a comment and ignored by the JavaScript interpreter.
<script type="text/javascript">
/*
This is our JavaScript Multiple line Comments
you can use this comment block as per your requirement!
*/
for (x=0; x < 10; x++)
{
document.write("x="+ x +"<br />");
}
</script>
JavaScript do not support nested comment block, so do not try this. Doing so may result in an error in code.





Thnx! perfect