Advertisement

Google Ad Slot: content-top

JS Comments

~1 min read · JS
On this page

In JavaScript, comments are used to write notes, explanations, or temporarily disable parts of code. Comments are ignored by the JavaScript engine during execution, making them useful for improving code readability and documentation.


There are two types of comments in JavaScript:


1. Single-Line Comments


Single-line comments start with //. Everything after // on that line will be treated as a comment

Example

JavaScript Comments

Try it yourself

2. Multi line comments


Multi-line comments start with /* and end with */. They can span multiple lines and are useful for longer explanations or to comment out blocks of code.

Example

Try it yourself