Skip to content

Latest commit

 

History

History
19 lines (15 loc) · 939 Bytes

06-comments.md

File metadata and controls

19 lines (15 loc) · 939 Bytes

Comments

In JavaScript, a comment is a piece of text that is ignored by the JavaScript interpreter and is not executed as part of the program. Comments are used to add notes, explanations, or documentation to the code, and are intended for human readers, not the computer.

JavaScript supports two types of comments:

  • Single-line comments: These start with // and continue until the end of the line.
    // this is a single line comment
  • Multi-line comments: These start with /_ and end with _/. They can span multiple lines.
    /*
    This is a
    multi-line comment
    */

Comments are used to make code more readable and understandable, which is especially important when working on large or complex programs. Comments can explain what the code is doing, how it works, and why it is necessary. Comments also help other developers understand the code and make it easier to maintain and update.