- Comments are sentences that we can write in our JavaScript code like our notes and it would not affect our code.
- Comments can be used for explaining code or stopping execution of some part of code.
- Comments are ignored by JavaScript
How to write comments in JavaScript
- For single line comments we can use two forward slashes
- For multi-line comments we use forward slash with star (asterisk) and the close the comment by star followed by forward slash.
1 2 3 4 5 6 7 8 |
<script type="text/javascript"> // for single line comments we can use two forward slashes /* for multi-line comments we use forward slash with star */ </script> |