Comments
Pythons Tutorials
Comments are lines of text in your code that are not executed by the browser. They serve as notes or annotations to explain the purpose, functionality, or logic behind specific lines or sections of code. Comments are crucial for documentation and collaboration in programming.
Types of Comments in JavaScript
JavaScript supports two types of comments:
Single-Line Comments
Single-line comments begin with //
and continue until the end of the line.
// This is a single-line comment
- The text following
//
is a comment and will not affect the code’s behaviour.
Multi-Line Comments
Multi-line comments start with /*
and end with */
. They can span multiple lines.
/* This is a
multi-line comment */
- Anything between
/*
and*/
is treated as a comment, even if it spans multiple lines.