Javascript Comments

Comments

 // for single line comments we can use two forward slashes
 
 /* for multiline comments
  we use forward slash with start
 */
      <script type="text/javascript">
// for single line comments we can use two forward slashes

/* for multiline comments
we use forward slash with start
*/
</script>

Javascript Comments

  • 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.