Skip to main content

Command Palette

Search for a command to run...

How to comment in javascript?

Published
1 min read

What are comments ?

Comments are lines of codes javascript intentionally ignore. They don't do anything. We can use comments in our code to make notes on what the code does so that it will be easier to read later time for us.

There are 2 types of comment in javascript

  • In-line comment
  • Multi-line comment

In-line comment

You can do in-line comment by typing // or by pressing Ctrl + / on windows and Command + / on mac. You can use in-line comment to comment a line in Javascript or to add note in the end of a line.

var num = 1; \\ 'in-line comment at the end of a code'

//var num = 1; this code will note run

Multi-line comment

To do a multi-line comment add /* in the starting of the comment and end it with */.

/*
This is a 
multi-line comment
*/

More from this blog

A

Amrith's Blog

10 posts