JavaScript Comments

JavaScript Comments

Summary: In this tutorial, you will learn about JavaScript comments and how to use them.

JavaScript comments

  1. What is JavaScript comments?

Commenting is a common task that we do always in programming.
Commenting is a way to leave notes to:

  • yourself (future self)
  • other people (developers who have to figure out your code)
  • make a JavaScript code inactive

JavaScript single line comment

To create a single line comment in JavaScript you write //

Using // will tell JavaScript to ignore the remainder of the text on the current line

// This is a single line comment in JavaScript

JavaScript multi-line comment

You can make a JavaScript multi-line comment comment starting with
/* and ending with */

/*
* This is a multi-line comment
* can span in multiple lines as the name says
*/

Note: Multi-line comment in JavaScript is the same as in CSS

JavaScript comments Definition and usage

Usually a JavaScript code is written by a programmer to do something.
For ex: create a great app or something

But comments are ignored by JavaScript intentionally. And they don’t do anything except making a code inactive, leave notes to yourself and other developers

Leave a Reply

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