Website Development Online Courses

Comments in JavaScript

What are comments in JavaScript?
Comment is a line of text or line of code which is completely ignored by the browser.

Why do we use comments in JavaScript?
When writing a code you may have some complex logic, that is confusing in that case you can include comments in the code. Not only it will help you to remember it later on but if someone else views your code they will also be able to understand the code.

For example, you are writing a code for registration so write a comment saying Registration code starts here. So in future, if you want to make some changes or you want to remove the code so you can find it easily by looking at the comment.

Please make a habit of writing a comment in the code.

There are two type of comments in JavaScript

  1. Single line comment
  2. Multi-line comment

Single line comment

Multi – line comment

Leave a Reply

Your email address will not be published. Required fields are marked * Copyright © 2017