top of page

Comments in JavaScript

Comments in JavaScript can be used to describe the code.

​

Comments in JavaScript can be used to make code not to run.

Single line comments

Single line comments are set using //. Everything after // on that line will not be run as code.

The comment you write can be anything, but if it's doesn't add value or understanding about the code. Then it probably should not be there. Use comments to explain the purpose of the code, or to add context to code some it's clear what it does.

Multi line comments

Multi line comments starts with /* and ends with */. Everything between /* and */ on that line will not be run as code.

Comments to prevent execution

You can use comments to prevent code from being executed. This can be useful when you test out different code.

©2022 - 2024 by JavaScript Schools.

bottom of page