Comments

Comments are statements that will not be executed by the interpreter, comments are used to mark annotations for other programmers or small descriptions of what your code does, thus making it easier for others to understand what your code does.

In Javascript, comments can be written in 2 different ways:

  • Line starting with //:
  1. // This is a comment, it will be ignored by the interpreter
  2. var a = "this is a variable defined in a statement";
  • Section of code starting with /*and ending with */, this method is used for multi-line comments:
  1. /*
  2. This is a multi-line comment,
  3. it will be ignored by the interpreter
  4. */
  5. var a = "this is a variable defined in a statement";

Mark the editor’s contents as a comment

  1. Mark me as a comment
  2. or I'll throw an error
  1. /*
  2. Mark me as a comment
  3. or I'll throw an error
  4. */
  1. assert(true);