How to write comments in the JavaScript code

  • Comments help us to read our code better in the future in case if we forgot what is happening on the particular line of code.
  • Comments can be helpful to the other developers who try to read our code.
  • Comments are also used to stop running a particular line in the code.
  • Comments are ignored by the interpreter.

Let’s learn now how to write comments in JavaScript.

There are two ways to write a comments in JavaScript.

Single line comment

// this is a single line comment in JavaScript

Mutliline comment or Block comment

/*
this is a multi-line

comment.

Hope

you

love me

*/